Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var x, y float64
	angle := 90.0

	for sc.Scan() {
		data := strings.Split(sc.Text(), ",")
		if data[0] == "0" && data[1] == "0" {
			break
		}
		meters, _ := strconv.Atoi(data[0])
		m := float64(meters)
		changedAngle, _ := strconv.Atoi(data[1])
		a := float64(changedAngle)

		radian := angle * math.Pi / 180
		x += m * math.Cos(radian)
		y += m * math.Sin(radian)
		angle -= a
	}
	fmt.Println(int(x))
	fmt.Println(int(y))
}

C++: #include <string>
#include <vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

#define PI 3.141592

int main(){

	int a,b; int c=90; double x=0; double y=0;
	while(true){
	cin >> a >> b;
	if(a==0 && b==0) break;
	x+=a*cos(c*PI/180);
	y+=a*sin(c*PI/180);
	c+=-b;

	}

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

	return 0;

    }

C++: /*Filename: aoj0016.cpp
 *Author: Mushiyo
 */

#include <stdio.h>
#include <cmath>

using namespace std;

int main() {
	double x = 0, y = 0;
	int direction = 90;
	int d = 0, t = 0;

	while (scanf("%d, %d", &d, &t) == 2) {
		if (d == 0 && t == 0) {
			break;
		}

		double dx = d * cos(direction * M_PI / 180.0);
		double dy = d * sin(direction * M_PI / 180.0);

		x += dx;
		y += dy;

		direction -= t;
		direction %= 360;
		if (direction < 0) {
			direction += 360;
		}
	}

	printf("%d\n", (int)x);
	printf("%d\n", (int)y);

	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <complex>
using namespace std;
const double PI = 3.141592653589793238462643383279502884L;

int main(int argc, char **argv)
{
  int degree = 90;
  int d, t;
  char c;
  complex<double> v(0, 0);

  while (cin >> d >> c >> t) {
    if (!d && !t)
      break;

    auto next = polar((double)d, degree*PI/180.0);
    v += next;
    degree = (degree - t) % 360;
  }
  printf("%d\n%d\n", (int)v.real(), (int)v.imag());
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define all(v) v.begin(),v.end()
template<typename T>T rad(T deg){return deg*M_PI/180;}

using namespace std;
int main() {
    double x=0,y=0,theta=0;
    double a,b;
    scanf("%lf,%lf",&a,&b);
    while(a||b){
        y += a*cos(rad(theta));
        x += a*sin(rad(theta));
        theta += b;
        scanf("%lf,%lf",&a,&b);
    }
    x = (abs(x)<0.5)?0:x;
    y = (abs(y)<0.5)?0:y;
    printf("%.0lf %.0lf",x,y);
    return 0;
}

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

using namespace std;
int main(void)
{
	int x = 0,y = 0;
	int hosu,kakudo;
	int kakudos = 90;
	while(scanf("%d,%d",&hosu,&kakudo))
	{
		if(hosu == 0 && kakudo == 0) break; 
		x += cos(kakudos * M_PI / 180) * hosu;
		y += sin(kakudos * M_PI / 180) * hosu;
		printf("%d\n",cos(kakudos * M_PI / 180) * hosu);
		kakudos -= kakudo;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

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

using namespace std;

int main() {
    int a=1;
    int b=1;
    
    double degree=90.0;
    
    double x=0.0;
    double y=0.0;

    while (a!=0&&b!=0){
        scanf("%d,%d",&a,&b);
        printf("%d%d\n",a,b);
        
        y+=(a*sin(degree* M_PI / 180));
        x+=(a*cos(degree* M_PI / 180));
        
        degree-=b;
    }
    
    cout<<(int)x<<" "<<(int)y;
    
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int r, t;
    int crtt = 90;
    double crtx = 0, crty = 0;
    while(1) {
        scanf("%d,%d", &r, &t);
        if (r == 0 && t == 0) break;
        crtx += cos(crtt * acos(-1) / 180) * r;
        crty += sin(crtt * acos(-1) / 180) * r;
        crtt -= t;
    }
    printf("%d\n%d\n", (int)crtx, (int)crty);
    return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;
void getValue(string& l, int& d, int& a)
{
	string::size_type p = l.find(',');
	d = atoi(l.substr(0, p).c_str());
	a = atoi(l.substr(p + 1).c_str());
}
int main()
{
	string line;
	int d, a;
	double x = 0.0, y = 0.0, angle = 90.0, toR = 3.14159265358979323846 / 180.0;
	while (true){
		cin >> line;
		getValue(line, d, a);
		if (0 == d && 0 == a)
			break;
		x += cos(angle * toR) * d;
		y += sin(angle * toR) * d;
		angle -= a;
	}
	cout << (int)x << "\n" << (int)y << "\n";
	return 0;
}

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

constexpr double PI = 3.1415926535;

double convert(int deg);
double adjust(double rad);

int main()
{
    double x = 0, y = 0;
    double rad = PI / 2;

    while (true) {
        int r, deg;
        char c;
        std::cin >> r >> c >> deg;

        if (r == 0 && deg == 0) {
            break;
        }

        x += r * cos(rad);
        y += r * sin(rad);

        rad = adjust(rad + convert(deg));
    }

    int ix = static_cast<int>((x > 0)? floor(x): -floor(-x));
    int iy = static_cast<int>((y > 0)? floor(y): -floor(-y));
    std::cout << ix << std::endl << iy << std::endl;

    return 0;
}

double convert(int deg)
{
    return (-deg * PI / 180);
}

double adjust(double rad)
{
    while (rad > PI) {
        rad -= 2 * PI;
    }
    while (rad < -PI) {
        rad += 2 * PI;
    }

    return rad;
}

C++: #include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
//#define int long long

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; 

inline int in(){int x;std::cin>>x;return x;}

struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;

template <class X> void print(X hoge){ cout << hoge << '\n'; }
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  int d, a;
  int now = 90;
  double x = 0, y = 0;

  while (scanf("%d,%d", &d, &a), d || a) {
    x += d * cos(M_PI * now / 180.0);
    y += d * sin(M_PI * now / 180.0);

    now = (now - a + 360) % 360;
  }

  print((int)x);
  print((int)y);

  return (0);
}

C++: #include <iostream>
#include <complex>
const double pi = 3.14159265358979;
using namespace std;

double radians(int degree){
	return double(degree)/180*pi;
}

int main(void){
	int r, angle=0, direction=90;
	char c;
	complex <double> p(0, 0);
	while (true){
		cin>>r>>c>>angle;
		if (r==0 && angle==0) break;
		p += polar((double)r, radians(direction));
		direction -= angle;

	}
	cout<<(int)p.real()<<endl;
	cout<<(int)p.imag()<<endl;
	return 0;
}