當前位置:首頁 » 編程語言 » c語言圓形

c語言圓形

發布時間: 2024-08-13 19:03:35

A. 怎麼用c語言畫出一個隨時間變化的圓形

  1. circle函數是TURBO C提供的圖形介面,用來畫圓。不屬於標准庫函數,不具備可移植性。
    函數名:circle
    功 能: 在給定半徑以(x, y)為圓心畫圓
    用 法:void far circle(int x, int y, int radius)

  2. 隨時間變化,可以用cleardevice函數清除屏幕,不斷畫半徑不同的圓。看起來就像是一個隨時間變化的圓形。

    函數名: cleardevice
    功 能: 清除圖形屏幕
    用 法: void far cleardevice(void);
    常式:

    #include<graphics.h>
    #include<stdlib.h>
    #include<stdio.h>
    #include<conio.h>
    intmain(void)
    {
    /*requestautodetection*/
    intgdriver=DETECT,gmode,errorcode;
    intmidx,midy;
    intradius=100;
    /**/
    initgraph(&gdriver,&gmode,"");
    /*readresultofinitialization*/
    errorcode=graphresult();
    if(errorcode!=grOk)/*anerroroccurred*/
    {
    printf("Graphicserror:%s ",grapherrormsg(errorcode));
    printf("Pressanykeytohalt:");
    getch();
    exit(1);/*terminatewithanerrorcode*/
    }
    midx=getmaxx()/2;
    midy=getmaxy()/2;
    setcolor(getmaxcolor());
    for(i=0;i<1000000;i++)if(i%50000==0){
    cleardevice();/*cleanthescreen*/
    circle(midx,midy,radius--);/*drawthecircle*/
    }
    getch();
    closegraph();
    return0;
    }

B. 怎麼用C語言畫一個圓形急~

#include<stdio.h>
#include<math.h>
int main()
{
double y;
int x,m;
for(y=10;y>=-10;y–)
{
m=2.5*sqrt(100-y*y); /*計算行y對應的列坐標m,2.5是屏幕縱橫比調節系數因為屏幕的
行距大於列距,不進行調節顯示出來的將是橢圓*/
for(x=1;x<30-m;x++) printf(" "); /*圖形左側空白控制*/
printf("*"); /*圓的左側*/
for(;x<30+m;x++) printf(" "); /*圖形的空心部分控制*/
printf("*\n"); /*圓的右側*/
}
return 0;
}

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:627
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:356
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:73
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:297
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:787
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:337
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:202
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:800
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:356
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:582