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 <stdio.h>
#include <string>
#include <math.h>
using namespace std;
#define PI 3.141592
int main(){
  float angle;
  float x=0,y=0;
  float d,t;
  string str;
  cin >> str;
  if(str[1]==','){
    d= str[0]-'0';
    if(str[2]=='-'){
      if(str.size()==4) t = (str[3]-'0')*(-1);
      else t = ((str[3]-'0')*10+(str[4]-'0'))*(-1);
    }else{
      if(str.size()==3) t = str[2]-'0';
      else t = (str[2]-'0')*10+(str[3]-'0');
    }
  }else if(str[2]==','){
    d= (str[0]-'0')*10+str[1]-'0';
    if(str[3]=='-'){
      if(str.size()==5) t = (str[4]-'0')*(-1);
      else t = ((str[4]-'0')*10+(str[5]-'0'))*(-1);
    }else{
      if(str.size()==4) t = str[3]-'0';
      else t = (str[3]-'0')*10+(str[4]-'0');
    }
  }else if(str[3]==','){
    d= (str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0');
    if(str[4]=='-'){
      if(str.size()==6) t = (str[5]-'0')*(-1);
      else t = ((str[5]-'0')*10+(str[6]-'0'))*(-1);
    }else{
      if(str.size()==5) t = str[4]-'0';
      else t = (str[4]-'0')*10+(str[5]-'0');
    }
  }
  while(d!=0||t!=0){
    x+=d*sin(angle/180*PI);y+=d*cos(angle/180*PI);
    angle+=t;
    //if(angle>360) angle-=360;
    //if(angle<-360) angle+=360;
    
    
    cin >> str;
    if(str[1]==','){
      d= str[0]-'0';
      if(str[2]=='-'){
	if(str.size()==4) t = (str[3]-'0')*(-1);
	else t = ((str[3]-'0')*10+(str[4]-'0'))*(-1);
      }else{
	if(str.size()==3) t = str[2]-'0';
	else t = (str[2]-'0')*10+(str[3]-'0');
      }
    }else if(str[2]==','){
      d= (str[0]-'0')*10+str[1]-'0';
      if(str[3]=='-'){
	if(str.size()==5) t = (str[4]-'0')*(-1);
	else t = ((str[4]-'0')*10+(str[5]-'0'))*(-1);
    }else{
	if(str.size()==4) t = str[3]-'0';
	else t = (str[3]-'0')*10+(str[4]-'0');
      }
    }else if(str[3]==','){
      d= (str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0');
      if(str[4]=='-'){
	if(str.size()==6) t = (str[5]-'0')*(-1);
	else t = ((str[5]-'0')*10+(str[6]-'0'))*(-1);
      }else{
	if(str.size()==5) t = str[4]-'0';
	else t = (str[4]-'0')*10+(str[5]-'0');
      }
    }
  }
  int x1=x,y1=y;
  printf("%d\n%d\n",x1,y1);
  return 0;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288
#endif

int main(int argc, char** argv)
{
  double dx = 0.0, dy = 1.0;

  double x = 0, y = 0;

  int d, t;

  for (int i = 0; fscanf(stdin, "%d,%d", &d, &t) == 2; i = (i + 1) % 4) {
    if (d == 0 && t == 0)
      break;

    x += d * dx;
    y += d * dy;
    
    double r = t / 180.0 * M_PI;

    double ndx =  cos(r) * dx + sin(r) * dy;
    double ndy = -sin(r) * dx + cos(r) * dy;

    dx = ndx;
    dy = ndy;
  }
  fprintf(stdout, "%d\n%d\n", int(x), int(y));
}

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

double cx,cy;
int cangle;
typedef pair<int,int> P;
queue<P> move;

int main()
{
    int dis,ang;
    while(true){
        scanf("%d%*c%d",&dis,&ang);
        if(dis==0 && ang==0)break;
        move.push(P(dis,ang));
    }
    cx = 0.0; cy = 0.0;
    cangle = 90;
    while(!move.empty()){
        P p = move.front();move.pop();
        cx += (double)p.first*cos(cangle*M_PI/180);
        cy += (double)p.first*sin(cangle*M_PI/180);
        cangle -= p.second;
    }

    cout << (int)cx << endl;
    cout << (int)cy << endl;

    return 0;
}

C++: #include <bits/stdc++.h>
#define P 3.14159265
using namespace std;
int main(){
  int a,b;
  double x=0,y=0,s=0;
  while(scanf("%d,%d",&a,&b),a&&b){
    x+=a*cos(s*M_PI/180);
    y+=a*sin(s*M_PI/180);
    s+=b;
  }cout<<(int)y<<endl<<(int)x<<endl;
}

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

int main(void){
	double x=0.0, y=0.0;
	double rad=M_PI/2.0;
	int r,a; char c;
	
	while(cin>>r>>c>>a){
		if( r==0 && a==0 ) break;
		double dx = r*cos(rad);
		double dy = r*sin(rad);
		rad -= a*M_PI/180.0;
		x+=dx; y+=dy;
	}

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

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

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

  while(1){
    scanf(" %d,%d",&a,&d);
    if(a==0&&d==0) break;
    //std::cout << (double)a << (double)d <<std::endl;
    x += (double)a*cos((double)pre_d*M_PI/180);
    y += (double)a*sin((double)pre_d*M_PI/180);
    pre_d += -d;
  }
  //std::cout << (double)a << std::endl;
  x -= 0.5;
  y -= 0.5;
  printf("%.0f\n%.0f\n",x,y);

}

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

int main(){
	string str;
	double x, y;
	int step, carb, arg;
	int p;
	bool minus;
	
	x = 0; y = 0; arg = 90;
	while(true){
		cin >> str;
		step = 0; carb = 0;
		p = 0;
		while(str[p] != ','){
			step = step * 10 + (str[p] - 48);
			p++;
		}
		p++;
		minus = false;
		while(p < str.size()){
			if(str[p] == '-') minus = true;
			else carb = carb * 10 + (str[p] - 48);
			p++;
		}
		if(step == 0 && carb == 0) break;
		if(!minus) carb *= -1;
		
		cout << step << " " << carb << endl;
		
		x += (double)step * cos((double)arg * 3.1415 / 180.0);
		y += (double)step * sin((double)arg * 3.1415 / 180.0);
		
		arg += carb;
	}
	
	cout << (int)x << endl << (int)y << endl;
	
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
using namespace std;

int main(){
	int x, r;
	char split;
	double cx = 0.0;
	double cy = 0.0;
	int cr = 0;
	while (cin >> x >> split >> r) {
		if (x == 0 && r == 0) break;
		cx += x * sin(cr * M_PI / 180);
		cy += x * cos(cr * M_PI / 180);
		cr += r;
	}
	cout << fixed << setprecision(0) << cx << endl;
	cout << fixed << setprecision(0) << cy << endl;

	return 0;
}

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

int main() {
    double x = 0;
    double y = 0;
    double const pi = acos(-1.0);
    int16_t theta = 90;
    int d, t;
    char c;

    for(cin >> d >> c >> t; d != 1 || t != 0; cin >> d >> c >> t) {
        x += d * cos(pi * theta / 180);
        y += d * sin(pi * theta / 180);
        theta -= t;
        if(theta < 0) {
            theta += 360;
        } else {
            theta %= 360;
        }
    }
    cout << static_cast<int32_t>(x) << endl;
    cout << static_cast<int32_t>(y) << endl;
    return 0;
}

C++: #include <iostream>
#include <cmath>
#define PI 3.14159265;
#define RAD (PI/180)

using namespace std;

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

	while(1) {
		cin >> m >> angle;
		if(m==0&&angle==0)
			break;
		x+=(double)m*cos(deg*RAD);
		y+=(double)m*sin(deg*RAD);
		deg-=angle;
	}

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

	return 0;

}