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++: /**************** 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(M_PI*vsum/180),R*sin(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(M_PI*vsum/180),R*sin(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 <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;
    return sin( rad );
}

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 <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
typedef double D;
const D EPS = 1e-8;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

typedef struct {
	double x, y;
} Point;

int sig(D a, D b) {
	if(a < b - EPS) return -1;
	if(a > b + EPS) return +1;
	return 0;
}

/** Problem0166 : Area of Polygon **/
double area(vector<Point> points)
{
	points.push_back(points[0]);
	
	double S=0;
	for (int i=0; i<points.size(); i++) {
		S += fabs(points[i].x*points[i+1].y - points[i+1].x*points[i].y);
	}
	
	return S/2;
}

int main()
{
	int M, N;
	while (cin>>M, M) {
		int angle=0;
		vector<Point> p1, p2;
		rep(k, M-1) {
			int t; cin>>t; angle+=t;
			Point p; p.x = cos(angle), p.y=sin(angle);
			p1.push_back(p);
		}
		
		angle=0;
		cin>>N;
		rep(k, N-1) {
			int t; cin>>t; angle+=t;
			Point p; p.x = cos(angle), p.y=sin(angle);
			p2.push_back(p);
		}
		
		double S1 = area(p1), S2 = area(p2);
		if (sig(S1, S2)>0)
			cout << 1 << endl;
		else if (sig(S1, S2)==0)
			cout << 0 << endl;
		else
			cout << 2 << endl;
	}
}

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


//----- 精査する関数 -----//
int f_check(int , int);


int main(void)
{
	//入力数
	int n = 0;
	//多角形その1
	int zu1 = 0;
	int zu2 = 0;

	while (true)
	{
		//多角形1
		cin >> n;
		if (n == 0)	{	return 0;	}

		//理想の角度
		int risou = 360 / n;
		//差の合計
		int sa1 = 0;

		for (int i = 0; i < n - 1; i++)
		{
			cin >> zu1;
			sa1 += f_check(zu1 , risou);
		}

		//多角形2
		cin >> n;

		//差の合計
		int sa2 = 0;
		//理想
		risou = 360 / n;
		for (int i = 0; i < n - 1; i++)
		{
			cin >> zu2;
			sa2 += f_check(zu2 , risou);
		}

		if (sa1 == sa2)
		{
			cout << "0" << endl;
		}
		else if (sa1 < sa2)
		{
			cout << "1" << endl;
		}
		else
		{
			cout << "2" << endl;
		}
	}

	return 0;
}



//*****----- 精査する関数 -----*****//

int f_check(int now , int risou)
{
	now -= risou;
	if (now < 0)
	{
		return (now * -1);
	}
	return now;
}