高中的时候做的,前两天看了看,挺好玩的。
只想说,当初的代码风格,,,,咳咳,算不上风骚!
#include <stdio.h> #include<math.h> int main ( void ) { double y; int yy, m, n, x; for ( yy = 0; yy <= 20; yy++ ) { y = 0.1 * yy; m = acos( 1 - y ) * 10; n = 45 * ( y - 1 ) + 31; for ( x = 0; x <= 62; x++ ) { if ( x == m && x == n ) printf ( "+" ); else if ( x == n ) printf ( "+" ); else if ( x == m || x == 62 - m ) printf ( "*" ); else printf ( " " ); } printf ( "\n" ); } return 0; }
运行之后
另一种方式——对比代码中的数字(主要是为了深入了解)
#include <math.h> #include <stdio.h> int main (void) { double y; int x, m, n; for (y = 0; y <= 2; y += 0.1) { m = acos(1 - y) * 10; n = 45 * (y - 1) + 31; for (x = 0; x < 63; x++) { if (x == m && x == n) putchar ('^'); else if (x == n) putchar ('+'); else if (x == m || x == 63 - m) putchar ('*'); else putchar (' '); } putchar ('\n'); } return 0; }
运行之后
没第一个效果好。。。。是吧?!
时间: 2024-10-10 01:29:09