当前位置: 代码迷 >> 图形/图像 >> 生趣图形之 二次函数与圆相交
  详细解决方案

生趣图形之 二次函数与圆相交

热度:583   发布时间:2016-05-13 02:26:20
趣味图形之 二次函数与圆相交

先看看它像什么????!

好吧(∩_∩),它像,,,,很多,发挥自己的创意去组合吧





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;}


运行之后

图片超神般存在







  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!