Go: package main

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

func main() {
	var a, b float64
	var x, y float64
	x = 0
	y = 0
	var now float64
	now = 90
	var info string
	for {
		fmt.Scan(&info)
		infos := strings.Split(info, ",")
		a_int, _ := strconv.Atoi(infos[0])
		b_int, _ := strconv.Atoi(infos[1])
		a = float64(a_int)
		b = float64(b_int)
		// println(a, b)
		if a == 0 && b == 0 {
			break
		}
		x += math.Cos(now*math.Pi/180)*a
		y += math.Sin(now*math.Pi/180)*a
		now -= b
	}
	fmt.Printf("%d\n%d\n", int(x), int(y))
}

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