用C輸出余弦曲線
整個代碼如下:
1
#include <stdio.h>
2
#include <math.h>
3
4
//using namespace std;
5
void printZB()
{
6
printf("-1.0 0 1.0\n");
7
printf("------------------------------------|---------------------------------->\n");
8
}
9
10
void printCos(float angle)
{
11
int blanks,postion;
12
postion = cos(angle)*35+35;
13
for(blanks=0;blanks<postion;blanks++)
14
printf(" ");
15
printf("*\n");
16
17
}
18
19
int main()
20

{
21
printZB();
22
float angle;
23
const float anglestep=0.22;
24
const float limit =9.42478;
25
for(angle=0.0;angle<limit;angle+=anglestep)
26
printCos(angle);
27
getchar();
28
return 0;
29
}
30

2

3

4

5



6

7

8

9

10



11

12

13

14

15

16

17

18

19

20



21

22

23

24

25

26

27

28

29

30
