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<cmath>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
#define EPS (1e-9)
int N,M;
double calc(int an){
  double rad = (double)an * M_PI/180.0;
  return 2.0-cos(rad);
}
bool equal(double a,double b){ return abs(a-b) < EPS; }
int main(){
  while(cin >> N && N ){
    double a1=0.0,a2=0.0;
    int an,suman=0;
    for(int i=0;i<N-1;i++){
      cin >> an;
      //cout << "an " <<calc(an) << endl;
      a1 += calc(an);
      suman+=an;
    }
    a1 += calc(360-suman);
    cin >> M;
    suman = 0;
    for(int i=0;i<M-1;i++){
      cin >> an;
      //    cout << "an " <<calc(an) << endl;
      a2 += calc(an);
      suman += an;
    }
    a2 += calc(360-suman);
    //    cout << a1 << " " <<a2<<endl;
    if( equal(a1,a2) ) cout << 0 << endl;
    else if( a1 > a2 ) cout << 1 << endl;
    else cout << 2 <<endl;
  }
}

C++: #include<cmath>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
#define EPS (1e-9)
int N,M;
double calc(int an){
  double rad = (double)an * M_PI/180.0;
  return sqrt(1.0-cos(rad)/2.0);
}
bool equal(double a,double b){ return abs(a-b) < EPS; }
int main(){
  while(cin >> N && N ){
    double a1=0.0,a2=0.0;
    int an,suman=0;
    for(int i=0;i<N-1;i++){
      cin >> an;
      //cout << "an " <<calc(an) << endl;
      a1 += calc(an);
      suman+=an;
    }
    a1 += calc(360-suman);
    cin >> M;
    suman = 0;
    for(int i=0;i<M-1;i++){
      cin >> an;
      //    cout << "an " <<calc(an) << endl;
      a2 += calc(an);
      suman += an;
    }
    a2 += calc(360-suman);
    //    cout << a1 << " " <<a2<<endl;
    if( equal(a1,a2) ) cout << 0 << endl;
    else if( a1 > a2 ) cout << 1 << endl;
    else cout << 2 <<endl;
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	while(cin>>n,n){
		double sum=0;
		int sumi=0;
		rep(i,n-1){
			int in;
			cin>>in;
			sum+=10000.0*sin(in*PI/180.0);
			sumi+=in;
		}
		sum+=10000.0*sin((360-sumi)*PI/180.0);
		cin>>n;
		double sumq=0;
		int sumiq=0;
		rep(i,n-1){
			int in;
			cin>>in;
			sumq+=10000.0*sin(in*PI/180.0);
			sumiq+=in;
		}
		sumq+=10000.0*sin((360-sumiq)*PI/180.0);
		if(sum>sumq)cout<<1<<endl;
		else if(sum<sumq)cout<<2<<endl;
		else cout<<0<<endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    double m1,m2;
    rep(i,n-1){
      int tmp;
      cin>>tmp;
      m1+=100*sin(PI*tmp/100.0);
    }
    cin>>n;
    rep(i,n-1){
      int tmp;
      cin>>tmp;
      m2+=100*sin(PI*tmp/100.0);
    }
    if(m1==m2)cout<<0<<endl;
    else if(m1>m2)cout<<1<<endl;
    else cout<<2<<endl;
  }

}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

int main(){

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		double areaA=0,areaB=0;
		int remain=360;
		for(int i=0;i<n-1;i++){
			double rad;
			int angle;
			scanf("%d",&angle);
			remain-=angle;
			rad = (double)angle / 180.0 * M_PI;
			areaA += 0.5*sin(rad);
		}

		areaA += 0.5*sin((double)remain / 180.0 * M_PI);

		remain=360;
		scanf("%d",&n);
		for(int i=0;i<n-1;i++){
			double rad;
			int angle;
			scanf("%d",&angle);
			remain-=angle;
			rad = (double)angle / 180.0 * M_PI;
			areaB += 0.5*sin(rad);
		}

		areaB += 0.5*sin((double)remain / 180.0 * M_PI);

		printf("%d\n",abs(areaA - areaB) < eps ? 0 :
			areaA > areaB ? 1 : 2);
	}
}

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

using namespace std;

double EPS=1e-10;
double pi=3.1415926535;

double calc(int x) {
  return sin((double)x*pi/180.0);
}
 

int main(void){
  int n,m;
  
  while(true){
    cin >> n;
    if(n==0)break;
    double sum1=0,sum2=0,s1=0,s2=0,v,s=360;
   
    for(int i=0;i<n-1;i++){
      cin >> v;
      s-=v;
      s1+=calc(v);
    }
    s1+=calc(s);
    cin >> m;
    s=360;
    for(int j=0;j<m-1;j++){
      cin >> v;
      s-=v;
      s2+=calc(v);
    }
    s2+=calc(s);
    if(s1>s2+EPS) cout << 1 << endl;
    else if(s1+EPS<s2) cout << 2 << endl;
    else cout << 0 << 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-9;
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;
	}
}