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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
#define PI asin(0.5)*12

void mainmain(){
	int n,m;
	while(cin>>n,n){
		double t1=0,t2=0;
		double tt1=360,tt2=360;
		rep(i,n-1){
			double t;
			cin>>t;
			tt1-=t;
			t1+=sin(t/PI);
		}
		t1+=sin(tt1/PI);
		cin>>m;
		rep(i,m-1){
			double t;
			cin>>t;
			tt2-=t;
			t2+=sin(t/PI);
		}
		t2+=sin(tt2/PI);
		if(t1-t2>EPS) cout<<1<<endl;
		else if(t1-t2<-EPS) cout<<2<<endl;
		else cout<<0<<endl; 
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#define EPS 1e-10
int m,n;
double v[400];
double s[2];

int check(){
	if(s[0]>s[1])return 1;
	if(s[1]>s[0])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]+=cos(v[i])*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]+=cos(v[i])*sin(v[i]);
		}
		printf("%d\n",check());
	}
	return 0;
}