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.Sin(v*math.Pi/180)
		}
		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.Sin(v*math.Pi/180)
		}
		if first_object > second_object+ 0.0000001 {
			fmt.Println(1)
		} else if second_object > first_object +0.0000001 {
			fmt.Println(2)
		} else {
			fmt.Println(0)
		}
	}
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#define EQ(x,y) (abs((x)-(y)) < EPS)
#define LT(x,y) ((x)-(y)<=-EPS)

#include <complex>
typedef complex<double> P;
typedef vector<P> vp;

double cross(P a, P b) {
	return (a.real()*b.imag() - a.imag()*b.real());
}

double to_radian(double degree) {
	return degree*PI/180;
}

double area(P a, P b, P c) {
	return abs(cross(c-a, b-a)*0.5);
}

struct state {
	int p;
	double c;
	state(int p, double c) : p(p), c(c) {};
	bool operator<(const state &o)const {
		return o.c<c;
	}
};

int main() {
	int m;
	while(cin >> m, m) {
		vp vm(m);
		int theta = 0.0, tmp;
		REP(i, m-1) {
			cin >> tmp;
			theta += tmp;
			vm[i] = P(cos(to_radian(theta)), sin(to_radian(theta)));
		}
		P p(0, 0);
		double S1 = 0.0;
		REP(i, m-1) {
			S1 += area(p, vm[i], vm[(i+1)%m]);
		}

		int n;
		cin >> n;
		vp vn(n);
		theta = 0.0;
		REP(i, n-1) {
			cin >> tmp;
			theta += tmp;
			vn[i] = P(cos(to_radian(theta)), sin(to_radian(theta)));
		}
		double S2 = 0.0;
		REP(i, n-1) {
			S2 += area(p, vn[i], vn[(i+1)%n]);
		}

		if(EQ(S1, S2)) {
			cout << 0 << endl;
		} else if(LT(S1, S2)) {
			cout << 2 << endl;
		} else {
			cout << 1 << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>

#define PI 3.141592654
#define EPS 1e-10

#define DEG_TO_RAD(theta) theta * PI / 180

struct point {
	double x;
	double y;
};

double getAreaOfTriangle(double sideA, double sideB, double theta)
{
	theta = DEG_TO_RAD(theta);
	return 0.5 * sideA * sideB * sin(theta);
}

int main(void)
{
	while(1) {
		int m;
		double area1 = 0;
		double area2 = 0;
		double theta;
		double lastTheta = 360;

		// 第1の多角形
		std::cin >> m;
		if(m == 0) {
			break;
		}
		for(int i = 0 ; i < m-1 ; i++) {
			std::cin >> theta;
			area1 += getAreaOfTriangle(1, 1, theta);
			lastTheta -= theta;
		}
		area1 += getAreaOfTriangle(1, 1, lastTheta);

		lastTheta = 360;
		// 第2の多角形
		std::cin >> m;
		if(m == 0) {
			break;
		}
		for(int i = 0 ; i < m-1 ; i++) {
			std::cin >> theta;
			area2 += getAreaOfTriangle(1, 1, theta);
			lastTheta -= theta;
		}
		area2 += getAreaOfTriangle(1, 1, lastTheta);

		if(fabs(area1 - area2) < EPS) {
			std::cout << '0' << std::endl;
		}
		else if(area1 > area2) {
			std::cout << '1' << std::endl;
		}
		else if(area1 < area2) {
			std::cout << '2' << std::endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


double getArea( double ang ) {
    double rad = ( 180.0 - ( ang / 2.0 + 90.0 ) ) / 180.0 * M_PI;
    double a = cos( rad );
    double b = 1.0;
    double c = 1.0;
    double s = ( a + b + c ) / 2.0;
    return sqrt( s * ( s - a ) * ( s - b ) * ( s - c ) );
}

double calc( VI v ) {
    double res = 0.0;
    int n = v.size();
    for ( int i = 0; i < n; ++ i ) {
        res += getArea( v[i] );
    }
    return res;
}

int solve( double s1, double s2 ) {
    if ( fabs( s1 - s2 ) < 1e-9 ) return 0;
    return s1 < s2 ? 2 : 1;
}

int main() {
    int m;
    while ( cin >> m && m ) {
        VI v1(m-1);
        for ( int i = 0; i < m-1; ++ i ) {
            cin >> v1[i];
        }
        int n;
        cin >> n;
        VI v2(n-1);
        for ( int i = 0; i < n-1; ++ i ) {
            cin >> v2[i];
        }
        double s1 = calc( v1 );
        double s2 = calc( v2 );
        cout << solve( s1, s2 ) << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>

using namespace std;


int main(void){
  int n,m;
  double v;
  
  while(cin >> n,n){
    double sum1=0,sum2=0,s1=0,s2=0;
    while(--n){
      cin >> v;
      sum1+=v;
      s1+=sin(v*M_PI/180);
    }
    s1+=sin((360-sum1)*M_PI/180);
    cin >> m;
    while(--m){
      cin >> v;
      sum2+=v;
      s2+=sin(v*M_PI/180);
    }
    s2+=sin((360-sum2)*M_PI/180);
    int res=(s1>s2)?1:(s1==s2)?0:2;
    cout << res << endl;
  }

  return 0;
}

C++: #include<cmath>
#include<iostream>
using namespace std;
int n,m;
int N[500],M[500];
double Sn[500],Sm[500],sumN,sumM,sum;
double pi = acos(-1.0);

double d2r(int d){
  return 2.0*pi*((double)d/360.0);
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    sum=0;
    sumM=sumN=0.0;
    for(int i=0;i<n-1;i++){
      cin>>N[i];
      sumN+= 1.0 * 1.0 * sin( d2r(N[i])  );
    }
    cin>>m;
    for(int i=0;i<m-1;i++){
      cin>>M[i];
      sumM+= 1.0 * 1.0 * sin( d2r(M[i])  );
    }
    sum=sumM-sumN;
    if(sum<0.0)sum*=-1.0;
    if(sum<0.00001){
      cout<<0<<endl;
    }else if(sumM<sumN){
      cout<<1<<endl;
    }else{
      cout<<2<<endl;
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <cmath>
 
#define s(a) sin(a*M_PI/180)
#define S(a) (float)a
 
int main()
{
  int n;
 
  while (scanf("%d", &n), n) {
    double a1 = 0.0, a2 = 0.0, in, rem = 360;
    for(int i = 0 ; i < n-1 ; i++){
      scanf("%lf" ,&in);
      rem -= in;
      a1 += s(in);
    }
    a1 += s(rem);
 
    scanf("%d" ,&n);
    rem = 360;
    for(int i = 0 ; i < n-1 ; i++){
      scanf("%lf" ,&in);
      rem -= in;
      a2 += s(in);
    }    
    a2 += s(rem);
 
    if(S(a1) > S(a2)){
      puts("1");
    }else if(S(a1) < S(a2)){
      puts("2");
    }else{
      puts("0");
    }
  }
 
  return 0;
}