在屏幕上用“*”显示0-360度的余弦函数cos(x)的曲线
- #include <stdio.h>
-
#include <math.h>
-
-
int main(int argc, char *argv[])
-
{
-
double y;
-
int x,m;
-
for(y=1; y>=-1; y-=0.1){
-
m = acos(y) * 10;
-
for(x=1; x<m; x++)
-
printf(" ");
-
printf("*");
-
-
for(; x<62-m; x++)
-
printf(" ");
-
printf("*\n");
-
}
-
-
return 0;
-
}
$ gcc 1.c -lm
进行编译,编译后进行运行
peng@ubuntu:quwei$ ./a.out
阅读(2887) | 评论(0) | 转发(0) |