Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func main() {
	scanner.Split(bufio.ScanWords)

	x, y := 0.0, 0.0
	rotate := 90.0

	for {
		line := nextString()
		if line == "0,0" {
			break
		}

		numbers := strings.Split(line, ",")
		di, _ := strconv.ParseFloat(numbers[0], 64)
		ai, _ := strconv.ParseFloat(numbers[1], 64)

		rotateRadian := math.Pi * rotate / 180.0
		x += di * math.Cos(rotateRadian)
		y += di * math.Sin(rotateRadian)

		rotate -= ai

		// fmt.Println(x, y)
	}

	fmt.Println(int(x))
	fmt.Println(int(y))
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	const double EPS=1e-10;
	double x=0,y=0;
	double dir=M_PI/2;
	for(int a,d;scanf("%d,%d",&a,&d),a|d;){
		x+=a*cos(dir);
		y+=a*sin(dir);
		dir-=d*M_PI/180;
	}
	printf("%d\n%d\n",int(x+EPS),int(y+EPS));
	
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>


int main()
{
double N,P=0;
double x,y;
double p=0,P1=0;
x=0;y=0;
while(1)
{
scanf("%lf,%lf",&N,&P1);
if((int)N==0&&(int)P1==0)break;

if(0<=(int)P&&(int)P<90){p=P*M_PI/180;x+=N*sin(p);y+=N*cos(p);}
else if(90<=(int)P&&(int)P<=180){p=(180-P)*M_PI/180;x+=N*sin(p);y-=N*cos(p);}
else if(0>(int)P&&(int)P>=-90){p=(-1*P)*M_PI/180;x-=N*sin(p);y+=N*cos(p);}
else if(-90>(int)P&&(int)P>=-180){p=(180+P)*M_PI/180;x-=N*sin(p);y-=N*cos(p);}
P=P1;
}
int X,Y;
X=(int)x;Y=(int)y;
printf("%d\n",X);printf("%d\n",Y);

return 0;
}

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

using namespace std;

double degToRad(int deg) {
  return deg * M_PI / 180;
}

int main(void) {
  double x = 0.0, y = 0.0;
  int deg = 90;

  while(1) {
    int l, d;
    scanf("%d,%d", &l, &d);
    if(l == 0 && d == 0) break;

    x += l*cos(degToRad(deg));
    y += l*sin(degToRad(deg));

    deg -= d;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;

  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T> int GetInt(T a){ return a >= 0 ? floor(a) : ceil(a); }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }
const double PI = 3.141592653583;
#define DegreeToRadian(Degree) ((float)Degree * (PI / 180.0f))

vector<string> split(string str, string delim)
{
    vector<string> result;
    int cutAt;
    while( (cutAt = str.find_first_of(delim)) != str.npos )
    {
        if(cutAt > 0)
        {
            result.push_back(str.substr(0, cutAt));
        }
        str = str.substr(cutAt + 1);
    }
    if(str.length() > 0)
    {
        result.push_back(str);
    }
return result;
}

int main()
{
	ifstream ifs("data.txt");
	int x, r, R = 0;
	pair<double, double> point = mp(0, 0);
	string str;
	
	while(ifs >> str)
	{
		vector<string> l = split(str, ",");

		x = r = 0;
		rep(i, l[0].size())
		{
			if(l[0][i] != '-')
				x += (l[0][i] - '0') * pow(10, (float)l[0].size() - i -1);
		}
		rep(i, l[1].size())
		{
			if(l[1][i] != '-')
				r += (l[1][i] - '0') * pow(10, (float)l[1].size() - i -1);
		}
		if(l[0][0] == '-')
			x *= -1;
		if(l[1][0] == '-')
			r *= -1;

		if(!(x || r))
			break;

		R = min(R, 360);

		point.first += sin(DegreeToRadian(R)) * x;
		point.second += cos(DegreeToRadian(R)) * x;

		R += r;
	}

	pint res = mp(GetInt(point.first), GetInt(point.second));
	printf("%d\n%d\n", res.first, res.second);
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  double x = 0, y = 0;
  int angle = 90;

  while(true){
    int d, a; 
    scanf("%d,%d", &d, &a);
    if(d == 0 && a == 0) break;

    x += d * cos(angle*acos(-1)/180.0);
    y += d * sin(angle*acos(-1)/180.0);
    angle -= a;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;
}

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

typedef struct {
    double x, y;
    double rot;
} person;

person me;

static const double PI = 6*asin( 0.5 );

void move(int f, int r){
    me.x += f * cos(me.rot * PI / 180);
    me.y += f * sin(me.rot * PI / 180);
    me.rot -= r;
}

int main(){
    int f, r; char c;
    me.x = 0, me.y = 0, me.rot = 0;
    while (cin >> f >> c >> r, f || r){
	move(f, r);
    }
    cout << -(int)me.y << endl;
    cout << (int)me.x << endl;
}

C++: #include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
	double x = 0, y = 0;
	int d = 90;
	int a, b;

	while (true)
	{
		scanf("%f,%f", &a, &b);
		if (a + b == 0) break;
		x += a * cos(d * 3.14159 / 180);
		y += a * sin(d * 3.14159 / 180);
		d -= b;
	}
	printf("%d\n", x);
	printf("%d\n", y);

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
double GetRad(int an){
  return (double)an*(M_PI/180.0);
}
main(){

  int x,an;
  double rx=0,ry=0;
  int ra=90;
  while(1){
    scanf("%d,%d",&x,&an);
    if(x==0 && an==0) break;
    double rad=GetRad(ra);
    rx+=cos(rad)*(double)x;
    ry+=sin(rad)*(double)x;
    ra-=an;
  }
  printf("%d\n%d\n",(int)rx,(int)ry);
  
}