先看看它像什么????!
好吧(∩_∩),它像,,,,很多,发挥自己的创意去组合吧
1.
/***二次函数与圆最完美图像***/ #include <stdio.h> #include <math.h> int main (void) { int m, n, x; double y; for ( y = 20; y >= -10; y-- ) { if ( y > 10 ) { m = 1.8 * sqrt(y); for ( x = 1; x <= 40; x++ ) { if ( x == 20 - m || x == 20 + m ) printf ( "*" ); else printf (" "); } } else if ( y >= 0 && y <= 10 ) { m = 1.8 * sqrt ( y ); n = 1.8 * sqrt ( 100 - y * y ); for ( x = 1; x <= 40; x++ ) { if ( x == 20 - m && x == 20 - n || x == 20 + m && x == 20 + n ) printf ("+"); else if ( x == 20 - m || x == 20 - n || x == 20 + m || x == 20 + n ) printf ("*"); else printf (" "); } } else { n = 1.8 * sqrt ( 100 - y * y ); for ( x = 1; x <= 40; x++ ) { if ( x == 20 - n || x == 20 + n ) printf ("*"); else printf (" "); } } printf ("\n"); } return 0; }
2.
/***二次函数与圆的叠加显示2***/ # include <stdio.h> # include <math.h> int main (void) { int x, m, n; double y; for (y = 10; y >= 0; y--) { m = 1.8 * sqrt( y ); n = 1.8 * sqrt( 100 - y * y ); for ( x = 1; x <= 40; x++ ) { if ( (x == 20 - m) && (x == 20 - n) || (x == 20 + m) && (x == 20 + n) ) printf ("+"); else if ( (x == 20 - m) || (x == 20 - n) || (x == 20 + m) || (x == 20 + n) ) printf ("*"); else printf (" "); } printf ("\n"); } for ( y = 0; y >= -10; y-- ) { n = 1.8 * sqrt( 100 - y * y ); for ( x = 1; x <= 40; x++ ) { if ( x == 20 - n || x == 20 + n ) printf ("*"); else printf (" "); } printf ( "\n" ); } return 0; }
运行之后(和第一个不同,要注意的是,屏幕的长宽比不一样)
3.
/***二次函数与圆的叠加显示3***/ # include <stdio.h> # include <math.h> int main (void) { int m, n; double y; for ( y = 10; y >= -10; y-- ) { m = 1.8 * sqrt ( abs(y) ); n = 1.8 * sqrt ( 100 - y * y ); for ( int x = 0; x <= 40; x++ ) { if ( (x == 20 - m) && (x == 20 - n) || ( x == 20 + m ) && ( x == 20 + n ) ) printf ( "+" ); else if ( (x == 20 - m) || (x == 20 - n) || ( x == 20 + m ) || ( x == 20 + n ) ) printf ( "*" ); else printf ( " " ); } printf ( "\n" ); } return 0; }
运行之后
图片超神般存在
时间: 2024-10-31 04:57:19