Title: Input positive integer n (n<360), output sine cosine of n degrees. Tip: Use Mathematical functions
The mathematical functions that need to be used:
Acos,sin,cos
Function header file: math.h
#include <math.h>
Define π:
#define PI ACOs (-1.0)
(1) Declare the positive integer variable of the input n,n the sin value of the s,n Cos value c
int N; // N: The positive integer input (n<360) double s,c; // S:n's sin value, C:n's Cos value
(2) Enter N:
scanf ("%d", &n);
(3) Seeking S and C:
S=sin ((pi*n)/d); C=cos ((pi*n)/N.);
(4) Output s,c:
printf ("%lf%lf", s,c);
Full code:
//P16 exercise 1-4 sine and cosine/*trigonometric Functions double sin (double);d ouble cos (double);d ouble tan (double);*/#include<cstdio>#include<math.h>#definePI ACOs (-1.0)//?intN//N: The positive integer input (n<360)DoubleS,c;//S:n's sin value, C:n's Cos valueintMain () {scanf ("%d",&N); S=sin ((pi*n)/ the); C=cos ((pi*n)/ the); printf ("%LF%LF", S,c); return 0;}
Introduction to the C + + algorithm race Classic Page16 exercise 1-4 sine and cosine