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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	double x=0, y=0, a, b, now = 90;
	char c;
	while (cin >> a >> c >> b, a || b) {
		x += a * cos(M_PI * now / 180);
		y += a * sin(M_PI * now / 180);
		now = now - b;
	}
	if (x >= 0) x = floor(x);
	else if (x < 0) x = ceil(x);
	if (y >= 0) y = floor(y);
	else if (y < 0) y = ceil(y);
		cout << x << " " << y << endl;
}

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

int main() {
    int s, d;
    char c;
    double px = 0.0, py = 0.0;
    double dir = 90.0;

    while(cin >> s >> c >> d) {
        if(s == 0 && d == 0) break;
        px += cos(dir * M_PI / 180.0) * s;
        py += sin(dir * M_PI / 180.0) * s;
        dir -= d;
    }
    cout << static_cast<int>(px) << endl;
    cout << static_cast<int>(py) << endl;
    return 0;
}

C++: #include <iostream>
#include <math.h>

#define PI 3.14159265

using namespace std;

int main(){
  int theta,x;
  double x_sum,y_sum,theta_sum;
  
  y_sum =0;
  scanf("%d,%d",&x,&theta);
  x_sum = x,theta_sum = theta;
  while(1){
    scanf("%d,%d",&x,&theta);
    if(x == 0 && theta == 0) break;
    x_sum += x*sin(theta_sum * PI / 180);
    y_sum += x*cos(theta_sum * PI / 180);
    theta_sum += theta;
  }

  cout << floor(x_sum) << endl << floor(y_sum) << endl;

  return 0;

}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	double x = 0, y = 0, rad = 90 * M_PI / 180;
	int a, b;
	while (scanf("%d,%d", &a, &b) && (a || b)) {
		x += a*cos(rad);
		y += a*sin(rad);
		//????????????
		rad -= b*M_PI / 180;
	}
	cout << (int)x << endl << (int)y << endl;
	return 0;
}

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

#define X 0
#define Y 1
#define PI 3.141592653589

int main()
{
    vector<double> udv = {0,1}; // 単位方向ベクトル
    vector<double> cur_position = {0, 0};

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

        cur_position.at(X) += udv.at(X)*step;
        cur_position.at(Y) += udv.at(Y)*step;

        // rotation
        double x =  cos(angle*PI/180.0)*udv.at(X) + sin(angle*PI/180.0)*udv.at(Y);
        double y = -sin(angle*PI/180.0)*udv.at(X) + cos(angle*PI/180.0)*udv.at(Y);
        udv.at(X) = x / sqrt(x*x+y*y);
        udv.at(Y) = y / sqrt(x*x+y*y);
    }    
    cout << static_cast<int>(cur_position.at(X)) << " " << static_cast<int>(cur_position.at(Y)) << endl;

    return 0;
}

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

int main(){
	double x = 0.0;
	double y = 0.0;
	double angle = 90.0;
	for(;;){
		double hos;
		double change;
		char c;
		cin >> hos >> c >> change;
		if(hos == 0 && change == 0) break;
		x += hos * cos(angle * 3.14159 / 180);
		y += hos * sin(angle * 3.14159 / 180);
		angle -= change;
	}
	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))

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(GetInt(point.first), GetInt(point.second));
	printf("%d\n%d\n", res.first, res.second);
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rad(x) x * M_PI / 180

int main(){
  double x = 0.0;
  double y = 0.0;
  int angle = 0.0;
  int d = 0;
  int r = 0;

  while (1){
    scanf("%d, %d", &r, &d);
    if (r == 0 && d == 0) break;
    y += r * sin(rad(angle));
    x += r * cos(rad(angle));

    angle += d;
  }

  printf("%.0lf\n%.0lf\n", y, x);
  return 0;
}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
double pi=3.14159265358;
int main(){
  double now=pi*0.5;
  double x=0.0,y=0.0;
  while(1){
    double a,b;
    scanf("%lf,%lf",&a,&b);
    if (a==0.0 and b==0.0)break;
    double xx=0.0,yy=0.0;
    xx=cos(now)*a;
    yy=sin(now)*a;
    x+=xx;
    y+=yy;
    now-=(b/180*pi);
    if(now>=2*pi)now-=2*pi;
    if(now<=-2*pi)now+=2*pi;
    
    
    
  }  
  printf("%d %d\n",(int)x,(int)y);
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
 
using namespace std;
 
int main(int argc, char *argv[]) {
  int a, b;
  double x, y, angle;
 
  x = y = angle = 0.0;
 
  while (true) {
    scanf("%d,%d", &a, &b);
    if (a == 0 && b == 0)
      break;
    y += a * cos(angle / 180 * M_PI);
    x += a * sin(angle / 180 * M_PI);
    angle += b;
  }
 
  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}

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

#define PI 3.1415926535898
#define ANGLE (PI/180.0)
int main(){
	int step,dir;
	double x=0.0, y=0.0, angle=0.0;
	
	while(1){
		scanf("%d,%d", &step, &dir);
		if(step==0 && dir==0) break;
		x += (double)(step) * sin( angle*ANGLE );
		y += (double)(step) * cos( angle*ANGLE );
		angle += (double)dir;
	}
	printf("%d\n%d\n", (int)x, (int)y);
}

C++: #include<iostream>
#include<cmath>
using namespace std;
double a, b; int c, d, e; char f;
#define A(D) sin(D*0.01745329252)
#define B(D) cos(D*0.01745329252)
int main() {
	while (true) {
		cin >> c >> f >> d;
		if (c == 0 && d == 0) { break; }
		a += 1.0*A(e) * c;
		b += 1.0*B(e) * c;
		e += d;
	}
	cout << (int)a << endl << (int)b << endl;
	return 0;
}