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 <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, 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))

int main()
{
	int x, r, R = 0;
	pair<double, double> point = mp(0, 0);

	while(cin >> x >> r && (x || r))
	{
		R = min(R, 360);

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

		R += r;
	}

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

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

#define PI 3.141592
#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	int x, y;
	tCell* prev;
	tCell* next;
};

class myArray{
public:
	myArray() : mSize( 0 ), head( NULL ), tail( NULL ){
		tail = new tCell;
		head = new tCell;
		head->prev = tail->next = NULL;
		head->next = tail;
		tail->prev = head;
		head->x = head->y = tail->x = tail->y = 0;
	}
	~myArray(){
		for ( int i = mSize; i > 0; --i ){
			--mSize;
			tCell* cell = tail->prev;
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
		SAFE_DELETE( head );
		SAFE_DELETE( tail );
	}
	void pushBack( int x, int y ){
		++mSize;
		tCell* cell = new tCell;
		cell->x = x;
		cell->y = y;
		cell->prev = tail->prev;
		cell->next = tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
	}
	tCell operator[]( int p ){
		if ( p >= mSize ){
			tCell* cell = NULL;
			return *cell;
		}
		tCell* cell = head;
		for( int i = 0; i <= p; ++i ){
			cell = cell->next;
		}
		return *cell;
	}
	int getSize(){ return mSize; }
private:
	int mSize;
	tCell* head;
	tCell* tail;
};

int main(){
	int move = 0, angle = 0;
	double x = 0.0, y = 0.0, theta = 90.0;
	char c;
	myArray mA;

	while ( cin >> move >> c >> angle ){
		if ( !move && !angle ) break;
		mA.pushBack( move, angle );
	}

	for ( int i = 0; i < mA.getSize(); i++ ){
		if ( i ){
			theta -= static_cast< double >( mA[ i - 1 ].y );
		}
		double rad = theta * PI / 180.0;
		x += mA[ i ].x * cos( rad );
		y += mA[ i ].x * sin( rad );
	}

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

	return 0;
}

C++: 
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>

using namespace std;

typedef complex<double> P;

int main(){

	P p;
	double c_r = 90;
	int x,r; char c;
	while(cin>>x>>c>>r,(x||r)){
		P add = P(x,0) * P(cos(c_r * M_PI / 180),sin(c_r* M_PI / 180));
		p += add;
		c_r -= r;
	}

	cout << (int)p.real() << " " << (int)p.imag() << endl;

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>
#include <cstdlib>
#include <typeinfo>
using namespace std;

int main(){
	double n, m, x = 0, y = 0, arg=0;
	while (1)
	{
		double a, b;
		scanf("%lf,%lf", &a, &b);
		if (a == 0 && b == 0)break;
		double rad = arg * PI / 180;
		x += a*cos(rad);
		y += a*sin(rad);
		arg += b; 
	
	}
	cout << (int)y << endl << (int)x << endl;
}