C / C ++ algorithms contest entry classic Page16 exercises 1-4 sine and cosine

Title: enter a positive integer n (n <360), the output of the sine cosine values ​​of degree n. Tip: Use mathematical functions

Code:

#include <cstdio>
#include <math.h>
#define the PI ACOS (-1.0) // definition of Pi, may be handwritten Pi = 3.1415926, so that very accurate

n int;
Double S, C; // S: SiN value of n, c: n cos value of
int main ()
{
Scanf ( "% D", & n);
n = (the PI * n) / 180 [; // The angle in radians converted
s = sin (n); // calculate
C = COS (n-);

the printf ( "%% LF LF", S, C); // output

return 0;
}

Guess you like

Origin www.cnblogs.com/Youio-bolg/p/11333847.html