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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const double PI = acos(-1);
const double EPS = 1e-10;
int sgn(double d) { return d > EPS ? 1 : d < -EPS ? -1 : 0; }
 
struct Point {
  double x, y;
  Point() {}
  Point (const double& x, const double& y) : x(x), y(y) {}
  Point& operator += (const Point& other) { x += other.x; y += other.y; return *this; }
  Point& operator -= (const Point& other) { x -= other.x; y -= other.y; return *this; }
  Point& operator *= (const double& factor) { x *= factor; y *= factor; return *this; }
  Point& operator /= (const double& factor) { x /= factor; y /= factor; return *this; }
};
using Vector = Point;
using Polygon = vector<Point>;
 
Point operator + (const Point&lhs, const Point& rhs) { return Point(lhs.x + rhs.x, lhs.y + rhs.y); }
Point operator - (const Point& lhs, const Point& rhs) { return Point(lhs.x - rhs.x, lhs.y - rhs.y); }
Point operator * (const Point& lhs, const double& factor) { return Point(lhs.x * factor, lhs.y * factor); }
Point operator * (const double& factor, const Point& rhs) { return Point(factor * rhs.x, factor * rhs.y); }
Point operator / (const Point& lhs, const double& factor) { return Point(lhs.x / factor, lhs.y / factor); }
double operator * (const Point& lhs, const Point& rhs) { return lhs.x * rhs.x + lhs.y * rhs.y; }
double operator ^ (const Point& lhs, const Point& rhs) { return lhs.x * rhs.y - lhs.y * rhs.x; }
bool operator == (const Point& lhs, const Point& rhs) { return sgn(lhs.x - rhs.x) == 0 && sgn(lhs.y - rhs.y) == 0; }
bool operator != (const Point& lhs, const Point& rhs) { return !(lhs == rhs); }
bool operator < (const Point& lhs, const Point& rhs) { return sgn(lhs.x - rhs.x) ? lhs.x < rhs.x : lhs.y < rhs.y; }
bool operator > (const Point& lhs, const Point& rhs) { return rhs < lhs; }
bool operator <= (const Point& lhs, const Point& rhs) { return !(lhs > rhs); }
bool operator >= (const Point& lhs, const Point& rhs) { return !(lhs < rhs); }
istream& operator >> (istream& is, Point& point) { return is >> point.x >> point.y; }
ostream& operator << (ostream& os, Point& point) { return os << "(" << point.x << "," << point.y << ")"; }
double norm(const Point& point) { return point.x * point.x + point.y * point.y; }
double abs(const Point& point) { return sqrt(norm(point)); }
double arg(const Point& point) { return atan2(point.y, point.x); }
Point polar(const double& a, const double& r) { return Point(cos(r) * a, sin(r) * a); }
bool sort_x(const Point& lhs, const Point& rhs) { return sgn(lhs.x - rhs.x) ? lhs.x < rhs.x : lhs.y < rhs.y; }
bool sort_y(const Point& lhs, const Point& rhs) { return sgn(lhs.y - rhs.y) ? lhs.y < rhs.y : lhs.x < rhs.x; }
 
double area(const Polygon& p) {
  int pz = p.size();
  if (pz < 3) return 0;
  double res = 0;
  for (int i = 0; i < pz; i++) {
    int prev = i == 0 ? pz - 1 : i - 1;
    int next = i + 1 == pz ? 0 : i + 1;
    res += p[i].x * (p[next].y - p[prev].y) / 2.;
  }
  return abs(res);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int m, n;
  while (cin >> m, m) {
    Point p(1, 0);
    Polygon ps(1, p);
    for (int i = 0; i < m - 1; i++) {
      double v;
      cin >> v;
      double t = v / 180 * PI;
      p = Point(p.x * cos(t) - p.y * sin(t), p.y * cos(t) + p.x * sin(t));
      ps.emplace_back(p);
    }
    cin >> n;
    Point q(1, 0);
    Polygon qs(1, q);
    for (int i = 0; i < n - 1; i++) {
      double v;
      cin >> v;
      double t = v / 180 * PI;
      q = Point(q.x * cos(t) - q.y * sin(t), q.y * cos(t) + q.x * sin(t));
      qs.emplace_back(q);
    }
    double pa = area(ps), qa = area(qs);
    cout << (sgn(pa - qa) > 0 ? 1 : sgn(pa - qa) < 0 ? 2 : 0) << endl;
  }

  return 0;
}

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(fabs(S-T) < EPS) cout << 0 << endl;
    else if(S+EPS > T) cout << 1 << endl;
    else if(S < T+EPS) cout << 2 << endl;
  }
  
  return 0;
}

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

const double EPS = 1e-10;
template<class T>
bool eq(const T& a, const T& b) {return abs(a - b) < EPS;}

double get_area(const vector<int>& vs) {
	int ang = 0;
	double res = 0;
	for (auto v : vs) {
		ang += v;
		res += sin(M_PI * v / 180.);
	}
	res += sin(M_PI * (360 - ang) / 180.);
	return res;
}

int main() {
	int m;
	while (cin >> m, m) {
		vector<int> vs1(m - 1);
		for (auto& v : vs1) cin >> v;
		int n;
		cin >> n;
		vector<int> vs2(n - 1);
		for (auto& v : vs2) cin >> v;

		double a = get_area(vs1);
		double b = get_area(vs2);
		if (eq(a, b)) cout << 0 << endl;
		else if (a > b) cout << 1 << endl;
		else cout << 2 << endl;
	}
	return 0;
}

C++: #include <cstdio>
#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 <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};


main(){
  int m;
  while(cin>>m,m){
    int v=0;
    long double s1=0;
    rep(i,m-1){
      int tv;
      cin>>tv;
      v+=tv;
      s1+=sin(M_PI/180*tv);
    }
    s1+=sin(M_PI/180*(360-v));
    v=0;
    cin>>m;
    rep(i,m-1){
      int tv;
      cin>>tv;
      v+=tv;
      s1-=sin(M_PI/180*tv);
    }
    s1-=sin(M_PI/180*(360-v));
    if(abs(s1)<EPS)cout<<0<<endl;
    else if(s1<0)cout<<2<<endl;
    else cout<<1<<endl;
  }
}