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 <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#include <algorithm>
using namespace std;

const double EPS = 1e-8;

int main() {
  for(int tci = 0; ; tci++) {
    double result[2];
    for(int ii = 0; ii < 2; ii++) {
      int m; scanf("%d", &m); if(m==0) goto done;
      int rdegree = 360;
      double area = 0.0;
      for(int i = 1; i < m; i++) {
        int d; scanf("%d", &d);
        area += sin(M_PI*d/180);
        rdegree -= d;
      }
      area += sin(M_PI*rdegree/180);
      result[ii] = area;
    }
    if(result[0]-result[1]>EPS)
      printf("1\n");
    else if(result[1]-result[0]>EPS)
      printf("2\n");
    else
      printf("0\n");
  }
done:
  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-12;
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+=100.0*sin(PI*tmp/180.0);
    }
    m1+=100.0*sin(PI*m/180.0);
    cin>>n;
    m=360;
    rep(i,n-1){
      int tmp;
      cin>>tmp;
      m-=tmp;
      m2+=100.0*sin(PI*tmp/180.0);
    }
    m2+=100.0*sin(PI*m/180.0);
    if(abs(m1-m2)<ESP)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;
		for(int i=0;i<n-1;i++){
			double rad;
			scanf("%lf",&rad);
			rad = rad / 180 * M_PI;
			areaA += sin(rad);
		}

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

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

C++: #include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#define EPS (1e-10)
#define PI 3.14159265358979323846264
using namespace std;


 
double rad(double d)
{
  return d*(PI/180.0);
}

double getArea(double r1,double r2,double d)
{
  return 0.5*r1*r2*sin(rad(d));
}


int main()
{
  int m;
  while(cin >> m,m)
    {
      double v,areaA,areaB;
      areaA = areaB = 0;
      
      for(int i=0;i<m-1;i++)
	{
	  cin >> v;
	  areaA += getArea(1.0,1.0,v);
	}
 
      cin >> m;
      for(int i=0;i<m-1;i++)
	{
	  cin >> v;
	  areaB += getArea(1.0,1.0,v);
	}
            
      if(areaA == areaB)
	cout << 0 << endl;
      else if(areaA > areaB)
	cout << 1 << endl;
      else
	cout << 2 << endl;
      
    }
  return 0;
}

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

using namespace std;

const double PI = acos(-1);

int main(void){
  int n,m;
  double v;
  
  while(cin >> n,n){
    double sum1=0,sum2=0,s1=0,s2=0;
    while(--n){
      cin >> v;
      sum1+=v;
      s1+=abs(sin(v));
    }
    s1+=abs(sin(360-sum1));
    cin >> m;
    while(--m){
      cin >> v;
      sum2+=v;
      s2+=abs(sin(v));
    }
    s2+=abs(sin(360-sum2));
    int res= (s1==s2)?0:(s1>s2)?1:2;
    cout << res << endl;
  }

  return 0;
}

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

using namespace std;


int main(void){
  int n,m;
  
  while(cin >> n,n){
    double sum1=0,sum2=0,s1=0,s2=0,v;
    for(int i=0;i<n-1;i++){
      cin >> v;
      sum1+=v;
      s1+=sin((double)v*M_PI/180);
    }
    s1+=sin((double)(360-sum1)*M_PI/180);
    cin >> m;
    for(int j=0;j<m-1;j++){
      cin >> v;
      sum2+=v;
      s2+=sin((double)v*M_PI/180);
    }
    s2+=sin((double)(360-sum2)*M_PI/180);
    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;
#define EPS (1e-15)
typedef long double ld;
int N,M;
ld calc(int an){
  ld rad = (ld)an * M_PI/180.0;
  return sqrt((ld)1.0-cos(rad)/(ld)2.0);
}
bool equal(ld a,ld b){ return abs(a-b) < EPS; }
int main(){
  while(cin >> N && N ){
    ld 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 <bits/stdc++.h>
using namespace std;

const double eps = 1e-8;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

int main() {
  while(1) {
    double sum[2];
    for(int i = 0; i < 2; ++i) {
      int m;
      cin >> m;
      if(!m) return 0;
      sum[i] = 0;
      double u = 0;
      while(--m) {
        double v;
        cin >> v;
        u += v;
        sum[i] += sin(M_PI * v / 180.0);
      }
      sum[i] += sin(M_PI * (360-u) / 180.0);
    }
    if(equals(sum[0], sum[1])) {
      cout << 0 << endl;
    } else if(sum[0] > sum[1]) {
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  }
  return 0;
}