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

熱點內容
asp搜索源碼 發布:2025-07-03 15:49:55 瀏覽:234
醫美大資料庫 發布:2025-07-03 15:47:07 瀏覽:356
c語言將二進制轉化為十進制 發布:2025-07-03 15:32:47 瀏覽:987
c語言幫助文檔 發布:2025-07-03 15:22:43 瀏覽:319
雙埠存儲器在情況下會發生讀寫沖突 發布:2025-07-03 15:12:54 瀏覽:270
快站資料庫 發布:2025-07-03 14:45:44 瀏覽:39
jsp獲取上傳文件路徑 發布:2025-07-03 14:44:46 瀏覽:569
php時間微妙 發布:2025-07-03 14:39:38 瀏覽:843
巨豆豆手機回復出廠密碼是什麼 發布:2025-07-03 14:35:19 瀏覽:474
演算法的三個 發布:2025-07-03 14:35:19 瀏覽:698