📜  在C图形中绘制圆

📅  最后修改于: 2021-05-25 21:30:06             🧑  作者: Mango

头文件graphics.h包含circle()函数,该函数绘制一个以(x,y)为中心且给定半径的圆。

句法 :

circle(x, y, radius);

where,
(x, y) is center of the circle.
'radius' is the Radius of the circle.

例子 :

输入:x = 250,y = 200,半径= 50输出: 输入:x = 300,y = 150,半径= 90输出:

下面是在C中画圆的实现:

// C Implementation for drawing circle
#include 
  
//driver code
int main()
{
    // gm is Graphics mode which is
    // a computer display mode that
    // generates image using pixels.
    // DETECT is a macro defined in
    // "graphics.h" header file
    int gd = DETECT, gm;
  
    // initgraph initializes the
    // graphics system by loading a
    // graphics driver from disk
    initgraph(&gd, &gm, "");
  
    // circle function
    circle(250, 200, 50);
  
    getch();
  
    // closegraph function closes the
    // graphics mode and deallocates
    // all memory allocated by
    // graphics system .
    closegraph();
  
    return 0;
}

输出 :

想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。