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++: #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",areaA == areaB ? 0 :
			areaA > areaB ? 1 : 2);
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int m;
  while(cin>>m){
    if(m==0) break;
    double s1=0,s2=0;
    int t1=0,t2=0;
    REP(i,m-1){
      int t;
      cin>>t;
      s1 += sin((double)t/180*M_PI);
      t1 += t;
    }
    s1+=sin((double)(360-t1)/180*M_PI);
    cin>>m;
    REP(i,m-1){
      int t;
      cin>>t;
      s2 += sin((double)t/180*M_PI);
      t2 += t;
    }
    s2 += sin((double)(360-t2)/180*M_PI);
    if(s1>s2){
      cout<<1<<endl;
    }else if(s2>s1){
      cout<<2<<endl;
    }else{
      cout<<0<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
long n,m,i,r,a;
double s,t,pi=3.14159265358927;
while(cin>>n){
if(n==0)break;
for(s=0,r=0,i=0;i<n-1;i++){
cin>>a;
s+=sin(a*pi/180);
r+=a;
}
s+=sin((360-r)*pi/180);
cin>>n;
for(t=0,r=0,i=0;i<n-1;i++){
cin>>a;
t+=sin(a*pi/180);
r+=a;
}
t+=sin((360-r)*pi/180);
if(s>t)cout<<'1'<<endl;
else if(s<t)cout<<'2'<<endl;
else cout<<'0'<<endl;
}
return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#define EPS 1e-10
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;
		for(int i=0;i<m-1;i++){
			scanf("%lf",&v[i]);
			v[i]=v[i]/360.0*M_PI;
			s[0]+=sin(v[i]);
		}
		scanf("%d",&n);
		for(int i=0;i<n-1;i++){
			scanf("%lf",&v[i]);
			v[i]=v[i]/360.0*M_PI;
			s[1]+=sin(v[i]);
		}
		printf("%d\n",check());
	}
	return 0;
}

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

int main(){

  int N,thita;
  while(1){
    double s1=0,s2=0;
    cin>>N;
    if(N==0) break;
    for(int i=0;i<N-1;i++){
      cin>>thita;
      s1+=abs( sin(thita) );
    }
    cin>>N;
    for(int i=0;i<N-1;i++){
      cin>>thita;
      s2+=abs( sin(thita) );
    }
    if(s1>s2) cout<<1<<endl;
    else if(s1<s2) cout<<2<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

C++: #include<cmath>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
int N,M;
int main(){
  while(cin >> N && N ){
    int a1=0,a2=0;
    int an,suman=0;

    for(int i=0;i<N-1;i++){
      int an;
      cin >> an;
      suman += an;
      a1 += 90-abs(90-an);
    }
    a1 += 90-abs(90-(360-suman));
    suman = 0;
    cin >> M;
    for(int i=0;i<M-1;i++){
      int an;
      cin >> an;
      suman += an;
      a2 += 90-abs(90-an);
    }
    a2 += 90-abs(90-(360-suman));
    // printf("%d %d\n",a1,a2);
    if( a1==a2 ) cout << 0 << endl;
    else if( a1 > a2 ) cout << 1 << 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;
		double r=2*M_PI;
		for(int i=0;i<m-1;i++)
		{
			double v;cin>>v;
			v*=2.0*M_PI/360;
			r-=v;
			a+=calc(sin(v/2)*2,1,1);
		}
		a+=calc(sin(r/2)*2,1,1);
		cin>>n;
		r=2*M_PI;
		for(int i=0;i<n-1;i++)
		{
			double v;cin>>v;
			v*=2.0*M_PI/360;
			r-=v;
			b+=calc(sin(v/2)*2,1,1);
		}
		b+=calc(sin(r/2)*2,1,1);
		cout<<a<<" "<<b<<endl;
		if(fabs(a-b)<1e-8)cout<<0<<endl;
		else if(a>b)cout<<1<<endl;
		else cout<<2<<endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

#define EPS (1e-5)

double conv(double dosu) {
  return dosu*M_PI/180.0;
}

int main() {
  int M;
  
  while(cin >> M && M) {
    double sum = 0.0;
    double S = 0.0;
    for(int i=0; i<M-1; i++) {
      double arg; cin >> arg;
      S += sin(conv(arg));
      sum += arg;
    }
    S += sin(conv(360-sum));
    
    int N; cin >> N;
    sum = 0;
    double T = 0.0;
    for(int i=0; i<N-1; i++) {
      double arg; cin >> arg;
      T += sin(conv(arg));
      sum += arg;
    }
    T += sin(conv(360-sum));
    
    if(S > T) cout << 1 << endl;
    else if(S < T) cout << 2 << endl;
    else cout << 0 << endl;
  }
  
  return 0;
}

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-8;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    double m1,m2;
    int m=360;
    rep(i,n-1){
      int tmp;
      cin>>tmp;
      m-=tmp;
      m1+=sin(PI*tmp/180.0);
    }
    m1+=sin(PI*m/180.0);
    cin>>n;
    m=360;
    rep(i,n-1){
      int tmp;
      cin>>tmp;
      m-=tmp;
      m2+=sin(PI*tmp/180.0);
    }
    m2+=sin(PI*m/180.0);
    if(abs(m1-m2)<ESP)cout<<0<<endl;
    else if(m1>m2)cout<<1<<endl;
    else cout<<2<<endl;
  }

}