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 <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
typedef complex<double> P;
typedef vector<P> G;

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double area2(const G &P) {
  double A = 0.0;
  for (int i = 0; i < P.size(); ++i)
    A += cross(curr(P, i), next(P, i));
  return A / 2.0;
}

P rotation(P v, double r){
  return P(v.real() * cos(r) - v.imag() * sin(r), v.real() * sin(r) + v.imag() * cos(r));
}

double calc(int N){
  G a(N);
  a[0] = P(1, 0);
  double r = 0.0;
  FOR(i, 1, N){
    int d; cin >>d;
    r += d * M_PI / 180.0;
    a[i] = rotation(P(1, 0), r);
  }
  return area2(a);
}

int main() {
  int N;
  while(cin >>N && N){
    double a = calc(N);
    cin >>N;
    double b = calc(N);
    cout <<(a > b ? 1 : (a < b ? 2 : 0)) <<endl;
  }
  return 0;
}

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

using namespace std;

#define PI acos(-1.0)

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		double a = 0.0;
		int cc = 360;
		int k;
		for (int i = 0; i < n-1; i++) {
			cin >> k;
			a += sin(PI*((double)k/360.0));
			cc -= k;
			//cout << a << endl;
		}
		a += sin(PI*((double)cc/360.0));
		int n2;
		cin >> n2;
		double b = 0.0;
		cc = 360;
		for (int i = 0; i < n2-1; i++) {
			cin >> k;
			b += sin(PI*((double)k/360.0));
			cc -= k;
			//cout << b << endl;
		}
		b += sin(PI*((double)cc/360.0));
		//cout << a << ' ' << b << endl;
		if (a == b) {
			cout << 0 << endl;
		} else if (a > b) {
			cout << 1 << endl;
		} else {
			cout << 2 << endl;
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int m;
	while(cin>>m,m){
		double a = 0;
		int sm = 0;
		FOR(i,m-1){ int x; cin>>x;  sm += x; a += sin(x/180.0*M_PI); }
		a += sin((360-sm)/180.0*M_PI);
		cin>>m;
		sm = 0;
		FOR(i,m-1){ int x; cin>>x;  sm += x; a -= sin(x/180.0*M_PI); }
		a -= sin((360-sm)/180.0*M_PI);
		if(abs(a) < 1e-8) puts("0");
		else puts(a > 0 ? "1" : "2");
	}

	return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<numeric>
using namespace std;
double Square(double x){return x*x;}
double D2R(double x){return x/180*3.14159265358979;}

double Area2(int angle[], double r, int n)
{
	double result=0;
	double s,a,b,c;
	for(int i = 0; i < n-1; ++i)
	{
		a=b=r;
		c=sqrt( Square( cos(D2R(angle[i])) - cos(D2R(angle[i]+angle[i+1])) ) +
				Square( sin(D2R(angle[i])) - sin(D2R(angle[i]+angle[i+1])) ) );
		s=(a+b+c)/2;
		result += (s*(s-a)*(s-b)*(s-c));
	}
	return result;
}
int main()
{
	int n,m,angle[361],i,j;
	while(scanf("%d",&m),m)
	{
		double s[2];
		int count[2]={m};
		for(i=0;i<2;++i)
		{
			angle[0]=0;
			for(j=1; j<count[i]; ++j) scanf("%d",&angle[j]);
			angle[count[i]] = 360-accumulate(angle,angle+count[i],0);
			s[i] = Area2(angle, 1, count[i]+1);

			if(i==0)scanf("%d",&n),count[1]=n;
		}
		if(fabs(s[0]-s[1])<0.001) puts("0");
		else if(s[0]>s[1]) puts("1");
		else puts("2");
	}
	return 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(10*cos(to_radian(theta)), 10*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(10*cos(to_radian(theta)), 10*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 <bits/stdc++.h>

using namespace std;

int main() {
  int M;
  
  while(cin >> M && M) {
    int sum = 0;
    double S = 0.0;
    for(int i=0; i<M-1; i++) {
      int arg; cin >> arg;
      S += sin(arg/(2*M_PI));
      sum += arg;
    }
    
    S += sin(sum/(2*M_PI));
    cin >> M;
    sum = 0;
    double T = 0.0;
    for(int i=0; i<M-1; i++) {
      int arg; cin >> arg;
      T += sin(arg/(2*M_PI));
      sum += arg;
    }
    
    T += sin(sum/(2*M_PI));
    
    if(abs(S-T) < 1e-5) cout << 0 << endl;
    else if(S < T) cout << 2 << endl;
    else cout << 1 << endl;
  }
  
  return 0;
}