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 "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define EPS 1e-9
#define PI 3.14159265358979323846
double calc(int theta){
    return sin(theta/360.0*PI)*cos(theta/360.0*PI);
}


double solve(vector<int> data){
    double ret=0;
    rep(i,data.size()){
        ret+=calc(data[i]);
    }
    return ret;
}


int main(){
    int n,m;
    while(cin>>n){
        if(n==0)break;
        double s1,s2;
        vector<int> data;
        int less=360;
        rep(i,n-1){
            int a;
            cin>>a;
            less-=a;
            data.pb(a);
        }
        data.pb(less);
        s1 = solve(data);
        
        less=360;
        data.clear();
        cin>>m;
        rep(i,m-1){
            int a;
            cin>>a;
            less-=a;
            data.pb(a);
        }
        data.pb(less);
        s2 = solve(data);
        if(fabs(s1-s2)<EPS)cout<<0<<endl;
        else if(s1>s2)cout<<1<<endl;
        else if(s1<s2)cout<<2<<endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

const double pi = 3.14159265;

int main(){
  int n;
  while(cin>>n, n){
    int sum = 0;
    int ang;
    double s1 = 0.0, s2 = 0.0;
    REP(i,n-1){
      cin>>ang;
      sum += ang;
      s1 += sin(pi * ang/180.0);
    }
    s1 += sin(pi * (360-sum)/180.0);

    int m;
    cin >> m;
    sum = 0;
    REP(i,m-1){
      cin>>ang;
      sum += ang;
      s2 += sin(pi * ang/180.0);
    }
    s2 += sin(pi * (360-sum)/180.0);

    if(abs(s1-s2) < 1e-15) puts("0");
    else if(s1 > s2) puts("1");
    else puts("2");
  }
  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/360.0*(2*M_PI));
      sum += arg;
    }
    
    S += sin((360-sum)/360.0*(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/360.0*(2*M_PI));
      sum += arg;
    }
    
    T += sin((360-sum)/360.0*(2*M_PI));
    
    if(S == T) cout << 0 << endl;
    else if(S < T) cout << 2 << endl;
    else cout << 1 << 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;
const double PI = 3.14159;
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;

double rad(double deg)
{
	return deg*2*PI/360;
}

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(rad(angle)), p.y=sin(rad(angle));
			p1.push_back(p);
		}
		
		angle=0;
		cin>>N;
		rep(k, N-1) {
			int t; cin>>t; angle+=t;
			Point p; p.x = cos(rad(angle)), p.y=sin(rad(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>
#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;
		for(int i=0;i<m-1;i++)
		{
			double v;cin>>v;
			a+=calc(sin(v/2)*2,1,1);
		}
		cin>>n;
		for(int i=0;i<n-1;i++)
		{
			double v;cin>>v;
			b+=calc(sin(v/2)*2,1,1);
		}
		if(fabs(a-b)<1e-10)cout<<0<<endl;
		else if(a>b)cout<<1<<endl;
		else cout<<2<<endl;
	}
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define PI 3.141592653589793238462643L
int K[100000];
long double SIN(long double b) { return sinl(b * PI / 180.0L); }
int main() {
	int N, cnt = 0; long double a, sum, s[2], V;
	while (true) {
		for (int i = 0; i < 2; i++) {
			cin >> N; V = 0.0L; sum = 0.0L; if (N == 0) { goto E; }
			for (int i = 0; i < N - 1; i++) { cin >> a; sum += SIN(a); V += a; }
			sum += sin(360.0L - V); s[i] = sum;
		}
		if (fabs(s[0] - s[1]) < 1e-9) { cout << '0' << endl; }
		else if (s[0] > s[1]) { cout << '1' << endl; }
		else if (s[0] < s[1]) { cout << '2' << endl; }
	}
E:;
	return 0;
}

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=360;
		for(int i=0;i<m-1;i++)
		{
			double v;cin>>v;
			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;
			r-=v;
			b+=calc(sin(v/2)*2,1,1);
		}
		b+=calc(sin(r/2)*2,1,1);
		if(fabs(a-b)<1e-12)cout<<0<<endl;
		else if(a>b)cout<<1<<endl;
		else cout<<2<<endl;
	}
}