趣味图形之 余弦函数cos

来源:互联网 发布:遥感影像数据预处理 编辑:程序博客网 时间:2024/04/30 17:43

高中的时候做的,前两天看了看,挺好玩的。


/***0-360余弦函数图像***/# include < stdio.h ># include < math.h >int main ( void ){  double y;  int m, i;  for ( y = 1; y >= -1; y -= 0.1 )  {     m = acos(y) * 10;      for ( i = 1; i < m; i++ )       {        printf(" ");      }      printf("*");      for ( ; i < 62 - m; i++ )      {        printf(" ");      }      printf("*\n");  }  return 0;} //第二种方式 /***余弦函数图像***/#include <stdio.h>#include <math.h>int main (void){    double m, x, y;    for ( y = 1; y >= -1; y -= 0.1)      {                                        m = acos(y);       for ( x = 0; x < m; x += 0.1)           putchar (' ');       putchar ('*');       for (; x < 6.2 - m; x += 0.1)       putchar (' ');       putchar ('*');       putchar ('\n');    }    return 0;}


运行之后





0 0