當前位置:首頁 » 編程語言 » 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;
}

熱點內容
數字化儲存與編譯是什麼 發布:2025-05-18 02:56:55 瀏覽:217
個人網站模板源碼 發布:2025-05-18 02:51:17 瀏覽:489
主伺服器ip地址 發布:2025-05-18 02:46:29 瀏覽:856
電腦配置太低玩不了絕地求生怎麼辦 發布:2025-05-18 02:38:39 瀏覽:797
存儲過程怎麼出錯了 發布:2025-05-18 02:37:16 瀏覽:368
32寸演算法 發布:2025-05-18 02:22:14 瀏覽:743
寶塔資料庫備份 發布:2025-05-18 02:14:18 瀏覽:192
安卓商店下載的光遇是什麼服 發布:2025-05-18 02:13:38 瀏覽:31
網頁挖礦源碼 發布:2025-05-18 02:13:34 瀏覽:307
centosftp伺服器設置參數 發布:2025-05-18 02:12:55 瀏覽:216