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>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
static const double eps = 1e-7;

void solve()
{
	int m;
	while(cin >> m, m)
	{
		double s1 = 0.0;
		for(int i = 0; i < m - 1; ++i)
		{
			int v;
			cin >> v;
			s1 += 0.5 * sin(M_PI * v / 180);
		}
		
		int n;
		cin >> n;
		double s2 = 0.0;
		for(int i = 0; i < n - 1; ++i)
		{
			int v;
			cin >> v;
			s2 += 0.5 * sin(M_PI * v / 180);
		}
		if(fabs(s1 - s2) < eps)
		{
			cout << 0 << endl;
		}
		else if(s1 > s2)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 2 << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int a, b;
	while(cin >> a, a){
		vector<int> n(a);
		int suma = 0, sumb = 0;
		rep(i, a-1){cin >> n[i]; suma += n[i];}
		n[a-1] = 360-suma;
		cin >> b;
		vector<int> m(b);
		rep(i, b-1){cin >> m[i]; sumb += m[i];}
		m[b-1] = 360-sumb;

		double p=0., q = 0.;
		rep(i, a) p += sin(n[i] * M_PI / 180);
		rep(i, b) q += sin(m[i] * M_PI / 180);


		if(abs(p-q) < eps) cout << 0 << endl;
		else if(p > q) cout << 1 << endl;
		else cout << 2 << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;
#define all(a) a.begin(),a.end()
double calc(double a,double b,double c)
{
	double s=(a+b+c)/2;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main()
{
	int m,n;
	
	while(cin>>m&&m)
	{
		double a=0,b=0;
		double r=2*M_PI;
		for(int i=0;i<m-1;i++)
		{
			double v;cin>>v;
			v*=2*M_PI/360;
			r-=v;
			a+=calc(sin(v/2)*2,1,1);
		}
		a+=calc(sin(r/2)*2,1,1);
		cin>>n;
		r=360;
		for(int i=0;i<n-1;i++)
		{
			double v;cin>>v;
			v*=2*M_PI/360;
			r-=v;
			b+=calc(sin(v/2)*2,1,1);
		}
		b+=calc(sin(r/2)*2,1,1);
		if(fabs(a-b)<1e-8)cout<<0<<endl;
		else if(a>b)cout<<1<<endl;
		else cout<<2<<endl;
	}
}

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

using namespace std;

int main(){
  for(int m;cin>>m,m;){
    int mr=360;
    double ms=0;
    for(int i=0;i<m-1;i++){
      int a;
      cin>>a;
      mr-=a;
      ms+=sin(acos(-1)*a/180);
    }
    ms+=sin(acos(-1)*mr/180);
    int nr=360;
    double ns=0;
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
      int a;
      cin>>a;
      nr-=a;
      ns+=sin(acos(-1)*a/180);
    }
    ns+=sin(acos(-1)*nr/180);
    int ans;
    if(ms>ns+1e-9){
      ans=1;
    }else if(ms+1e-9<ns){
      ans=2;
    }else{
      ans=0;
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: /**************** Geometrical Library ****************/

#include<cmath>
#include<vector>
#include<algorithm>

#define	EPS	1e-8

enum {CCW=1,CW=-1,ON=0};

#define	mp	make_pair
#define	pb	push_back

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy):x(xx),y(yy){}
};

class Line:public vector<Point>{
public:
	Line(const Point &a,const Point &b){
		pb(a),pb(b);
	}
};

class Segment:public Line{
public:
	Segment(const Point &a,const Point &b):Line(a,b){}
};

class Polygon:public vector<Point>{};

class Circle{
public:
	Point c;
	double r;
	Circle(const Point &cc,double rr) : c(cc),r(rr){}
};

Point &operator +=(Point &a,const Point &b){
	a.x+=b.x,a.y+=b.y;
	return a;
}

Point &operator -=(Point &a,const Point &b){
	a.x-=b.x,a.y-=b.y;
	return a;
}

Point &operator *=(Point &a,double c){
	a.x*=c,a.y*=c;
	return a;
}

Point &operator /=(Point &a,double c){
	a.x/=c,a.y/=c;
	return a;
}

Point operator +(const Point &a,const Point &b){
	Point c=a;
	return c+=b;
}

Point operator -(const Point &a,const Point &b){
	Point c=a;
	return c-=b;
}

Point operator *(double c,const Point &a){
	Point b=a;
	return b*=c;
}

Point operator /(const Point &a,double c){
	Point b=a;
	return b/=c;
}

bool operator <(const Point &a,const Point &b){
	return (a.x==b.x)?(a.y<b.y):(a.x<b.x);
}

bool operator >(const Point &a,const Point &b){
	return b<a;
}

double cross(const Point &a,const Point &b){
	return a.x*b.y-a.y*b.x;
}

double area(const Polygon &pl){
	int n=pl.size();
	double a=0;
	for(int i=0;i<n;i++)	a+=cross(pl[i],pl[(i+1)%n]);
	return abs(a)/2;
}

/**************** Library END ****************/

#include<cstdio>

int main(){
	const double R=1000;
	for(int m;scanf("%d",&m),m;){
		Polygon pl1;	pl1.pb(Point(R,0));
		for(int i=1,vsum=0;i<m;i++){
			int v;	scanf("%d",&v);
			vsum+=v;
			pl1.pb(Point(R*cos(2*M_PI*vsum/180),R*sin(2*M_PI*vsum/180)));
		}
		int n;	scanf("%d",&n);
		Polygon pl2;	pl2.pb(Point(R,0));
		for(int i=1,vsum=0;i<n;i++){
			int v;	scanf("%d",&v);
			vsum+=v;
			pl2.pb(Point(R*cos(2*M_PI*vsum/180),R*sin(2*M_PI*vsum/180)));
		}
		double a1=area(pl1),a2=area(pl2);
		if(a1>a2+EPS)		puts("1");
		else if(a2>a1+EPS)	puts("2");
		else	puts("0");
	}
	return 0;
}

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

double calc( double* sinv, int x )
{
	double xv = 0.0;
	int angle = 360;
	for( int i = 0; i < x - 1; ++i ){
		int a;
		cin >> a;
		xv += sinv[ a ];
		angle -= a;
	}
	xv += sinv[ angle ];
	return xv;
}

int main()
{
	double sinv[ 180 ] = {0.0};
	for( int i = 1; i <= 90; ++i ){
		sinv[ i ] = sinv[ 180 - i ] = sin( static_cast<double>( i ) );
	}

	int m, n;
	while( cin >> m && m ){
		double mv = calc( sinv, m );
		cin >> n;
		double nv = calc( sinv, n );
		int ans = 0;
		if( mv > nv ){
			ans = 1;
		}else if( mv < nv ){
			ans = 2;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#define EPS 1e-9
int m,n;
double v[1000];
double s[2];

int check(){
	if(s[0]>s[1]+EPS)return 1;
	if(s[1]>s[0]+EPS)return 2;
	return 0;
}

int main(void){
	while(1){
		scanf("%d",&m);
		if(m==0)break;
		s[0]=s[1]=0.0;
		for(int i=0;i<m-1;i++){
			scanf("%lf",&v[i]);
			v[i]=v[i]/180.0*M_PI;
			s[0]+=sin(v[i]);
		}
		scanf("%d",&n);
		for(int i=0;i<n-1;i++){
			scanf("%lf",&v[i]);
			v[i]=v[i]/180.0*M_PI;
			s[1]+=sin(v[i]);
		}
		printf("%d\n",check());
	}
	return 0;
}