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<cmath>
using namespace std;
int main(){

  int m,n,v,m2,n2;
  double rad,S1,S2;
  
  while(1){
    
    cin >>m;
    
    if(m == 0)break;
    
    S1=0;
    S2=0;
    m2=360;
    n2=360;
    
    for(int i=0 ; i < m-1 ; i++){
      cin >>v;
      m2-=v;
      rad=v*(M_PI/180);
      S1+=sin(rad)/2;
    }
    
    rad=m2*(M_PI/180);
    S1+=sin(rad)/2;
    
    cin >>n;
    
    for(int i=0 ; i < n-1 ; i++){
      cin >>v;
      n2-=v;
      rad=v*(M_PI/180);
      S2+=sin(rad)/2;
    }
    
    rad=n2*(M_PI/180);
    S2+=sin(rad)/2;
    
    if(fabs(S1-S2) < 10e-8 ){
      cout <<"0"<<endl;
    }else if ( S1 > S2 ){
      cout <<"1"<<endl;
    }else{
      cout <<"2"<<endl;
    }
    
  }
  
  return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1 << 28
#define EPS 1e-10
#define PI acos(-1)

using namespace std;

struct Point 
{
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}
    
	double distance (const Point &o) const 
	{
        return sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y));
    }

    Point operator+(const Point &o) const 
	{
        return Point(x+o.x, y+o.y);
	}

 
    Point operator-(const Point &o) const 
	{
        return Point(x-o.x, y-o.y);
    }
 	
    Point operator*(const double m) const 
	{
   	   return Point(x*m, y*m);
    }

    Point operator/(const double d) const 
	{
       return Point(x/d, y/d);
    }

    double cross(const Point &o) const 
	{
       return x * o.y - y * o.x;
    }
 
    double dot(const Point &o) const 
	{
        return x * o.x + y * o.y;
    }
 
    double atan() const 
	{
        return atan2(y, x);
    }

    double norm() const 
	{
        return sqrt(dot(*this));
    }

	double area_abs(const Point &a,const Point &b) const
	{
		double t = (a.x - x) * (b.y - y);
		double t2 = (a.y - y) * (b.x - x);
		double areas = abs(t-t2);
		return areas/2;
	}

	//符号付き面積
	double area(const Point &a,const Point &b)
	{
		return ((a.x - x) * (b.y - y)) + ((b.x - x) * (y - a.y));
	}
	//線分abが自身の含まれているのかどうか判断する
	int between(const Point &a,const Point &b)
	{
		if(area(a,b) != 0) return 0;

		if(a.x != b.x)
		{
			return ((a.x <= x) && (x <= b.x) || (a.x >= x) && (x >= b.x));
		}
		else
		{
			return ((a.y <= y) && (y <= b.y) || (a.y >= y) && (y >= b.y));
		}
	}

	double distance_seg(const Point& a,const Point& b)
	{
		if((b-a).dot(*this-a) < EPS) 
		{
			return (*this-a).norm();
		}
		if((a-b).dot(*this-b) < EPS)
		{
			return (*this-b).norm();
		}
		return abs((b-a).cross(*this-a)) / (b-a).norm();
	}

	//点a,b,cからなる三角形の中に自身が含まれているかどうか
	bool hitPolygon(const Point& a,const Point& b,const Point& c)
	{
		double t = (b-a).cross(*this-b);
		double t2 = (c-b).cross(*this-c);
		double t3 = (a-c).cross(*this-a);
		
		if((t > 0 && t2 > 0 && t3 > 0) || ( t < 0 && t2 < 0 && t3 < 0))
		{
			return 1;
		}

		return 0;
	}
};
//多角形の面積
//0 = n-1;
double areOfPoint(const vector<Point> &p)
{
	double sum = 0.0;
	rep(i,p.size()-1)
	{
		sum += p[i].x * p[i+1].y - p[i+1].x * p[i].y;
	}

	return abs(sum/2);
}


int main()
{
	int n,m;
	while(cin >> n && n)
	{
		vector<Point> a,b;
		double theta = 0,temp,x,y;

		a.push_back(Point(1,0));
		b.push_back(Point(1,0));

		rep(i,n-1)
		{
			cin >> temp;
			theta += temp;
			
			x = cos(theta*PI/180);
			y = sin(theta*PI/180);

			a.push_back(Point(x,y));
		}

		a.push_back(Point(1,0));

		theta = 0;
		cin >> m;
		rep(i,m-1)
		{
			cin >> temp;
			theta += temp;
			
			x = cos(theta*PI/180);
			y = sin(theta*PI/180);

			b.push_back(Point(x,y));
		}
		b.push_back(Point(1,0));

		double areaA = areOfPoint(a);
		double areaB = areOfPoint(b);

		if(areaA == areaB)
		{
			cout << 0 << endl;
		}
		else if(areaA > areaB)
		{
			cout << 1 << endl;	
		}
		else if(areaA < areaB)
		{
			cout << 2 << 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;
		double rest=360.0;
		for(int i=0;i<m-1;i++){
			scanf("%lf",&v[i]);
			rest-=v[i];
			v[i]=v[i]/180.0*M_PI;
			s[0]+=sin(v[i]);
		}
		s[0]+=sin(rest/180.0*M_PI);
		scanf("%d",&n);
		rest=360.0;
		for(int i=0;i<n-1;i++){
			scanf("%lf",&v[i]);
			rest-=v[i];
			v[i]=v[i]/180.0*M_PI;
			s[1]+=sin(v[i]);
		}
		s[1]+=sin(rest/180.0*M_PI);
		printf("%d\n",check());
	}
	return 0;
}

C++: #include<cmath>
#include<iostream>
using namespace std;
int n,m,o;
int N,M;
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(){
  //cout<<d2r(270)/pi<<endl;
  while(1){
    cin>>n;
    if(n==0)break;
    sumM=sumN=0.0;

    o=0;
    for(int i=0;i<n-1;i++){
      cin>>N;
      o+=N;
      if(N>=180)continue;
      sumN += 1.0 * 1.0 * sin( d2r(N)  ) * 0.5;
    }
    sumN += 1.0 * 1.0 * sin( d2r(360-o)  ) * 0.5;
    
    o=0;
    cin>>m;
    for(int i=0;i<m-1;i++){
      cin>>M;
      o+=M;
      if(M>=180)continue;
      sumM += 1.0 * 1.0 * sin( d2r(M)  ) * 0.5;
    }
    sumM += 1.0 * 1.0 * sin( d2r(360-o)  ) * 0.5;

    sum=sumM-sumN;
    if(sum<0.0)sum*=-1.0;
    if(sum<0.0000001){
      cout<<0<<endl;
    }else if(sumM<sumN){
      cout<<1<<endl;
    }else{
      cout<<2<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <map>
#include <string>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main() {
    int n;
    while(cin >> n && n) {
        double s1 = 0, t1 = 0;
        double cur = 0;
        rep(i,n-1){
            double t; cin >> t;
            s1 += sin(t/180*acos(-1));
            cur += t;
        }
        s1 += sin((360-cur)/180*acos(-1));

        cin >> n;
        cur = 0;
        rep(i,n-1){
            double t; cin >> t;
            t1 += sin(t/180*acos(-1));
            cur += t;
        }
        t1 += sin((360-cur)/180*acos(-1));

        if(abs(s1-t1) < 1e-8) cout << 0 << endl;
        else if(s1 > t1) cout << 1 << endl;
        else if(s1 < t1) cout << 2 << endl;
    }
}