Go: package main

import (
	"bufio"
		"os"
	"strconv"
	"math"
	"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		m, _ := strconv.Atoi(scanner.Text())
		if m == 0 {
			break
		}
		args1 := make([]float64, m)
		x := 0.0
		for i := 0; i < m-1; i++ {
			scanner.Scan()
			tmp, _ := strconv.ParseFloat(scanner.Text(), 64)
			x += tmp
			args1[i] = tmp
		}
		args1[m-1] = 360-x
		first_object := 0.0
		for _, v := range args1 {
			first_object+= math.Abs(math.Sin(v))
		}
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		args2 := make([]float64, n)
		y := 0.0
		for i := 0; i < n-1; i++ {
			scanner.Scan()
			tmp, _ := strconv.ParseFloat(scanner.Text(), 64)
			y += tmp
			args2[i] = tmp
		}
		args2[n-1] = 360-y
		second_object := 0.0
		for _, v := range args2 {
			second_object+= math.Abs(math.Sin(v))
		}
		if first_object < second_object {
			fmt.Println(2)
		} else if first_object == second_object {
			fmt.Println(0)
		} else if first_object > second_object {
			fmt.Println(1)
		}
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <complex>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

// 多角形の符号付面積
D area(const VP& ps) {
  D a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}

int main() {
  int n, m;
  while (cin >> m, m) {
    VP ps1(m);
    int curDeg = 0;
    rep(i,m-1) {
      ps1[i] = polar(1., curDeg * M_PI / 180);
      int v;
      cin >> v;
      curDeg += v;
    }
    ps1[m-1] = polar(1., curDeg * M_PI / 180);

    cin >> n;
    VP ps2(n);
    curDeg = 0;
    rep(i,n-1) {
      ps2[i] = polar(1., curDeg * M_PI / 180);
      int v;
      cin >> v;
      curDeg += v;
    }
    ps2[n-1] = polar(1., curDeg * M_PI / 180);

    D areaDiff = area(ps1) - area(ps2);
    if (EQ(areaDiff, 0)) cout << 0;
    else if (areaDiff > 0) cout << 1;
    else cout << 2;
    cout << endl;
  }
  return 0;
}

C++: #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
	while(1){
		int m, v[400];
		int arg=360;
		double a=0, b=0;
		
		scanf(" %d", &m);
		if(m==0) break;
		for(int i=0; i<m-1; ++i){
			scanf(" %d", &v[i]);
			arg-=v[i];
			a+=sin(v[i]*M_PI/180.0);
		}
		a+=sin(arg*M_PI/180.0);
		
		arg=360;
		scanf(" %d", &m);
		for(int i=0; i<m-1; ++i){
			scanf(" %d", &v[i]);
			arg-=v[i];
			b+=sin(v[i]*M_PI/180.0);
		}
		b+=sin(arg*M_PI/180.0);
		
		//printf(" a=%lf, b=%lf\n", a, b);
			
		if(a>b) printf("1\n");
		else if(a<b) printf("2\n");
		else printf("0\n");
	}
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){

  int m,n,v,m2,n2;
  double rad,S1,S2;
  
  while(1){
    
    cin >>m;
    
    if(m == 0)break;
    
    S1=0;
    S2=0;
    m2=360;
    n2=360;
    
    for(int i=0 ; i < m-1 ; i++){
      cin >>v;
      m2-=v;
      rad=v*(M_PI/180);
      S1+=sin(rad)/2;
    }
    
    rad=m2*(M_PI/180);
    S1+=sin(rad)/2;
    
    cin >>n;
    
    for(int i=0 ; i < n-1 ; i++){
      cin >>v;
      n2-=v;
      rad=v*(M_PI/180);
      S2+=sin(rad)/2;
    }
    
    rad=n2*(M_PI/180);
    S2+=sin(rad)/2;
    
    if( S1 == S2 ){
      cout <<"0"<<endl;
    }else if ( S1 > S2 ){
      cout <<"1"<<endl;
    }else{
      cout <<"2"<<endl;
    }
    
  }
  
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const double PI = acos(-1);

double rad(double x)
{	return x * PI / 180.0;	}

int main()
{
    int n;
	while(cin >> n && n)
	{
		double S = 0;
		double v;
		
		double d = 360;
		rep(i, n - 1)
		{
			cin >> v; d -= v;
			S += sin(rad(v));
		}
		
		S += sin(rad(d));
		
		d = 360;
		cin >> n;
		rep(i, n - 1)
		{
			cin >> v; d -= v;
			S -= sin(rad(v));
		}
		
		S -= sin(rad(d));
		
		cout << (abs(S) < EPS ? 0 : (0 < S ? 1 : 2)) << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double PI = acos(-1.0);

int main()
{
    for(;;){
        vector<double> area(2, 0.0);
        for(int i=0; i<2; ++i){
            int n;
            cin >> n;
            if(n == 0)
                return 0;

            int rest = 360;
            while(--n > 0){
                int a;
                cin >> a;
                area[i] += sin(a/180.0*PI);
                rest -= a;
            }
            area[i] += sin(rest/180.0*PI);
        }

        if(area[0] > area[1])
            cout << '1' << endl;
        else if(area[0] < area[1])
            cout << '2' << endl;
        else
            cout << '0' << endl;
    }
}

C++: #include <cmath>
#include <iostream>
using namespace std;

#define PI	3.1415926535
#define EPS	0.0000000001

int main()
{
	int n,a;
	int a1,a2;
	double h1,h2;

	while(cin >> n, n)
	{
		a1=a2=0;
		h1=h2=0;
		while(--n)
		{
			cin >> a;
			a1 += a;
			h1 += sin(a*PI/360.0);
		}
		cin >> n;
		while(--n)
		{
			cin >> a;
			a2 += a;
			h2 += sin(a*PI/360.0);
		}

		h1 += sin((360-a1)*PI/360.0);
		h2 += sin((360-a2)*PI/360.0);

		if(-EPS<h1-h2 && h1-h2<EPS)
		{
			cout << 0 << endl;
		}
		else if(h1>h2)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 2 << endl;
		}
	}

	return 0;
}