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 <cassert>
#include <cmath>
#include <iostream>

int main()
{
    double x = 0;
    double y = 0;
    double a = M_PI_2;
    while(true){
        int d, t;
        char c;
        std::cin >> d >> c >> t;
        if(d == 0 && t == 0) break;
        x += d * std::cos(a);
        y += d * std::sin(a);
        a += (-t * M_PI / 180);
    }
    std::cout << int(x) << std::endl;
    std::cout << int(y) << std::endl;
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
double na;
double nx,ny;

int main(){
	int d;
	int a;
	na=90;
	nx=0;
	ny=0;
	while(1){
		scanf("%d,%d",&d,&a);
		if(d==0&&a==0)break;
		nx+=(double)d*cos(M_PI*na/180);
		ny+=(double)d*sin(M_PI*na/180);
		na-=a;
	}
	printf("%d\n%d\n",(int)nx,(int)ny);
}

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

int main(void)
{
	/*

	const double pi = std::acos(-1.0);

	double r, t;

	for(;;)
	{
		std::cin >> r >> t;

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

		double tRad = t/360.0*2.0*pi;

		std::cout << "(x,y)=" << '(' << r*cos(tRad) << ',' << r*sin(tRad) << ")\n";
	}
	*/
	const double pi = std::acos(-1.0);

	double rIn, tIn;//tInの単位は°

	char c;

	double t = 0;//tの単位はrad

	double x=0, y=0;

	for(;;)
	{
		std::cin >> rIn >> c >> tIn;

		if(rIn==0 && tIn==0)
		{
			break;
		}

		x += rIn*(std::sin(t));

		y += rIn*(std::cos(t));

		t += tIn/360.0*2.0*pi;//°→radの変換した後tに足す

	}

	int xI =x, yI=y;

	std::cout << xI << '\n' << yI << '\n';
	
}

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

using namespace std;

#define PI acos(-1)

double toRad(double ang){
    return (ang*PI/180);
}

int main(){
    char c;
    double a,b,x = 0,y = 0,rd = 0;
    while(cin >> a >> c >> b){
	if(a == 0 && b == 0) break;
	x += a*sin(toRad(rd));
	y += a*cos(toRad(rd));
	rd += b;
    }
    cout << (int)x << endl << (int)y << endl;
    
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>


int main()
{
double N,P=0;
double x,y;
double p=0,P1;
x=0;y=0;
while(1)
{
scanf("%lf,%lf",&N,&P1);
if((int)N==0&&(int)P1==0)break;

if(0<=(int)P&&(int)P<90){p=P*M_PI/180;x+=N*sin(p);y+=N*cos(p);}
else if(90<=(int)P&&(int)P<=180){p=(180-P)*M_PI/180;x+=N*sin(p);y-=N*cos(p);}
else if(0>(int)P&&(int)P>=-90){p=(-1*P)*M_PI/180;x-=N*sin(p);y+=N*cos(p);}
else if(-90>(int)P&&(int)P>=-180){p=(180+P)*M_PI/180;x-=N*sin(p);y-=N*cos(p);}
P=P1;
}
int X,Y;
X=(int)x;Y=(int)y;
printf("%d\n",X);printf("%d\n",Y);

return 0;
}

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

int main(){
double x,y,angle,t,r;
x=0;
y=0;
angle=M_PI/2;
while(1){
scanf("%lf,%lf",&r,&t);
if(r==0&&t==0)break;
x+=r*cos(angle);
y+=r*sin(angle);
angle+=t*M_PI/180;
}
printf("%.0f\n%.0f\n",-x,y);
return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main(){
	double x=0,y=0,angle=90,a,b;
	int ix,iy;
	for(;;){
		scanf("%lf,%lf",&a,&b);
		if(a==0 && b==0){break;}
		x+=(cos(angle*3.1415926/180))*a;
		y+=(sin(angle*3.1415926/180))*a;
		angle-=b;
	}
	ix=x;
	iy=y;
	printf("%d\n%d\n",ix,iy);
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define PI 3.14159265358979323846264

using namespace std;

int main()
{
	double x=0,y=0,theta=90;
	int a,b;

	scanf("%d,%d",&a,&b);
	while(a!=0 && b!=0){
		x+=a*cos(theta*PI/180);
		y+=a*sin(theta*PI/180);

		theta-=b;
		scanf("%d,%d",&a,&b);

	}

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

	return 0;
}

C++: #include <stdio.h>
#include <complex>
using namespace std;
typedef complex<double> P;
const double pi = atan2(0.0, -1.0);

P unit(double t) { return P(cos(t), sin(t)); }

int main() {
    P cp(0, 0);
    int cd = 90;
    for (;;) {
        int L, d;
        scanf("%d,%d", &L, &d);
        if (L == 0 && d == 0) break;
        cp += (double)L*unit(pi*cd/180);
        cd -= d;
    }
    printf("%d\n%d\n", (int)cp.real(), (int)cp.imag());
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	int r,t,T;
	complex<double> ans(0.0,0.0);

	T=90;

	while(scanf("%d,%d",&r,&t)>0){
		ans+=polar((double)r,(double)T*PI/180.0);
		T-=t;
	}
	
	cout<<(int)ans.real()<<endl<<(int)ans.imag()<<endl;

	return 0;

}

C++: #include<stdio.h>
#include<math.h>
int main()
{
double N,P;
double x,y;

x=0;y=0;
while(1)
{
scanf("%lf,%lf",&N,&P);
if((int)N==0&&(int)P==0)break;
double p;
if(0<=(int)P&&(int)P<90){p=P*3.141592/180;x+=N*sin(p);y+=cos(p);}
else if(90<=(int)P&&(int)P<=180){p=(180-P)*3.141592/180;x+=N*sin(p);y-=cos(p);}
else if(0>(int)P&&(int)P>=-90){p=(-1*P)*3.141592/180;x-=N*sin(p);y+=cos(p);}
else if(-90>(int)P&&(int)P>=-180){p=(180+P)*3.141592/180;x-=N*sin(p);y-=cos(p);}
}
int X,Y;
X=(int)x;Y=(int)y;
printf("%d\n",X);printf("%d\n",Y);

return 0;
}

C++: #include <bits/stdc++.h>

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned uint;

const double PI = acos(-1.0);

double X, Y, P;
int D, A;

int main(void) {
	X = 0.0;
	Y = 0.0;
	P = 90.0;

	for ( ; scanf("%d,%d", &D, &A) == 2 && !(A == 0 && D == 0); ) {
		X = X + cos(P * PI / 180) * D;
		Y = Y + sin(P * PI / 180) * D;
		P -= A;
	}
	printf("%d\n%d\n", (int) X, (int) Y);
    return 0;
}

C++: #include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
using namespace std;
int main() {
  double x, y, walk, deg, rad = M_PI_2;
  char c;
  while (cin >> walk >> c >> deg) {
    if (walk == 0 && deg == 0) break;
    x += walk * cos(rad);
    y += walk * sin(rad);
    rad -= deg * M_PI / 180;
  }
  cout << (int) x << endl << (int) y << endl;
}

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

using namespace std;

int main() {
    int r, degree;
    int sum_degree = 0;
    double wx = 0, wy = 0;
    char comma;

    while (true) {
        cin >> r >> comma >> degree;
        if (!r && !degree) {
            break;
        }

        // the input of sin and cos is radian
        wx += r * sin(M_PI / 180.0 * sum_degree);
        wy += r * cos(M_PI / 180.0 * sum_degree);

        sum_degree = (sum_degree + degree) % 360;
    }

    cout << (int)wx << "\n" << (int)wy << endl;

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	cout << fixed << setprecision(0);
	ios :: sync_with_stdio(false);
	db d, t; char c;
	db x, y, a;
	while(cin >> d >> c >> t) {
		a -= t;
		x += d * cos(a);
		y += d * sin(a);
	}
	cout << x << ' ' << y << '\n';
	return 0;
}

C++: #include <iostream>
#include<cmath>
#include<iomanip>
#include<stdio.h>
using namespace std;

const double pi = 3.1415926535897932385;

int main()
{
	int direction = 0, distance = 0;
	double x = 0, y = 0, a = 0;
	while (scanf("%d,%d", &distance, &direction)!=EOF)
	{
		if (direction == distance && direction == 0)
		{
			cout << (int)y << '\n' << (int)x << endl;
			x = y = a = 0;
		}
		else
		{
			x += (distance*cos(a));
			y += (distance*sin(a));
			a += (double)direction / 180 * pi;
		}
	}
	return 0;
}