#プログラム大喜利 出題その(3)

Twitter. It's what's happening.

やることは中学校で習うレベルなので、わざわざググる程のものでもなく出来る筈。

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PARAM_R  200.0f
#define PARAM_THETA  (M_PI / 12.0)

typedef struct {
	double x, y;
} VEC;

/*
 * 角度の単位は [rad] で与える。
 */
void polar2rect(double r, double theta, VEC * retVector)
{
	retVector->x = r * cos(theta);
	retVector->y = r * sin(theta);
}

int main(int argc, char **argv)
{
	VEC result;
	
	polar2rect(PARAM_R, PARAM_THETA, &result);
	printf("(%f, %f)\n", result.x, result.y);
	return EXIT_SUCCESS;
}

とっても簡単。初級問題。