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<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);
}

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 += sin(rad(v));
	}
 
      cin >> m;
      for(int i=0;i<m-1;i++)
	{
	  cin >> v;
	  areaB += sin(rad(v));
	}
            

      if(areaA == areaB)
	cout << 0 << endl;
      else if(areaA > areaB)
	cout << 1 << endl;
      else 
	cout << 2 << endl;
      
    }
  return 0;
}

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

using namespace std;

const double Eps = 1e-4;
const double PI = 4*atan(1.0);

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		double area[2];
		area[0] = area[1] = 0;
		for (int w = 0; w < 2; ++w)
		{
			for (int i = 1; i < n; ++i)
			{
				int v;
				scanf("%d", &v);
				area[w] += sin(v*PI / 180);
			}
			if (!w)
				scanf("%d", &n);
		}
		if (abs(area[0] - area[1]) < Eps)
			puts("0");
		else if (area[0] > area[1])
			puts("1");
		else
			puts("2");
	}

	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;
		double S1=0;
		rep(k, M-1) {
			int t; cin>>t;
			angle+=t;
			S1 += sin(rad(t));
		}
		S1 += sin(rad(360-angle));
		
		angle=0;
		cin>>N;
		double S2=0;
		rep(k, N-1) {
			int t; cin>>t;
			angle+=t;
			S2 += sin(rad(t));
		}
		S2 += sin(rad(360-angle));
		
		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<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=0,m2=0;
    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;
  }

}

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 * M_PI;
			areaA += sin(rad);
		}

		areaA += sin((double)remain / 180 * 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 * M_PI;
			areaB += sin(rad);
		}

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

		printf("%d\n",areaA == areaB ? 0 :
			areaA > areaB ? 1 : 2);
	}
}

C++: #include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const double EPS = 1e-8;

int main()
{
	int m;
	while(scanf("%d", &m), m){
		double sm1 = 0.0;
		rep(i, m-1){
			int deg;
			scanf("%d", &deg);
			sm1 += sin(deg*M_PI/180.0);
		}
		
		int n;
		scanf("%d", &n);
		
		double sm2 = 0.0; 
		rep(i, n-1){
			int deg;
			scanf("%d", &deg);
			sm2 += sin(deg*M_PI/180.0);
		}
		
		if(fabs(sm1 - sm2) < EPS)
			puts("0");
		else
			puts(sm1>sm2 ? "1" : "2");
	}
}

C++: #include <iostream>
#include <cmath>
using namespace std;
const int PI = 3.1415926535897932384;

int main(){
    double n;
    
    while(cin >> n,n){
        double angle,nn = (n-2)*180;
        double first = 0 , second = 0;
        for(int i = 0 ; i < n-1 ; i++){
            cin >> angle;
            first += cos((angle*PI)/180.0);
            nn -= angle;
        }

        first += cos((nn*PI)/180.0);
   
        cin >> n;
        nn = (n-2)*180;
        for(int i = 0 ; i < n-1 ; i++){
            cin >> angle;
            second += cos((angle*PI)/180.0);
            nn -= angle;
        }
        second += cos((nn*PI)/180.0);
  
        if((float)first == (float)second) cout << '0' << endl;
        else if((float)first > (float)second) cout << '1' << endl;
        else cout << '2' << endl;
    }
    
    return 0;
}