[Functions]D. Liang 5.21 Using the trigonometric functions.c

Description

Print the sin value and cos value of degrees from 0 to 360 with increaments of 10 degrees.

Example Input

None

Example Output

      Degree         Sin         Cos
           0      0.0000      1.0000
          10     -0.5440     -0.8391
          20      0.9129      0.4081
         ...
         350     -0.9589     -0.2836
         360      0.9589     -0.2837

*The last line is a newline character.
You should set the width of print field of each column to 12, set the precision of floating-point numbers to 4 and fixed, justify the output to the right.

Note:

1. Output format required by the title;
2. Add 10 units to degree in turn, not one unit.

//   Date:2020/4/3 
//   Author:xiezhg5
#include <stdio.h>
#include <math.h>    //库文件中有计算三角函数的公式 
int main(void)
{
    printf("      Degree         Sin         Cos\n");
    int i;
    for(i=0;i<=360;i=i+10)
    {
    	printf("%12d%12.4lf%12.4lf\n",i,sin(i),cos(i));
    }
    return 0; 
}
发布了165 篇原创文章 · 获赞 124 · 访问量 5624

猜你喜欢

转载自blog.csdn.net/qq_45645641/article/details/105288845
今日推荐