當前位置:首頁 » 編程語言 » c語言輸入半徑和圓心
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言輸入半徑和圓心

發布時間: 2022-10-16 12:02:29

⑴ 求c語言代碼,要求讀入圓心的坐標、圓的半徑以及一個點的坐標,判斷這個點是在圓內、圓上還是在圓外。

#include<stdio.h>
voidmain()
{
inta,b,c,d,r,k;
scanf("(%d,%d)%d(%d,%d)",&a,&b,&r,&c,&d);
k=(a-c)*(a-c)+(b-d)*(b-d)-r*r;
if(k>0)printf("點在圓外");
elseif(k<0)printf("點在圓內");
elseprintf("點在圓上");
}


運行示例截圖:

已編譯執行,無誤。注意讀取格式的規定,輸入時格式不要輸錯

⑵ 用C語言編寫一個程序,輸入半徑,輸出圓周長、圓面積和圓球體積(圓周率取3.14)

#include <stdio.h>void main()
{
float r;
printf("請輸入圓的半徑: ");
scanf("%f",&r);
printf("圓的周長是: %f\n",(2*3.14*r));//求出圓周長
printf("圓的面積是: %f\n",(3.14*r*r));//求出圓面積
}

⑶ c語言怎麼輸入半徑求圓面積和周長

C語言輸入半徑求圓面積和周長具體如下圖:

同圓內圓的直徑、半徑的長度永遠相同,圓有無數條半徑和無數條直徑。圓是軸對稱、中心對稱圖形。對稱軸是直徑所在的直線。 同時,圓又是「正無限多邊形」,而「無限」只是一個概念。圓可以看成由無數個無限小的點組成的正多邊形,當多邊形的邊數越多時,其形狀、周長、面積就都越接近於圓。

圓的相關性質:

1、在同圓或等圓中,相等的弧所對的圓周角等於它所對的圓心角的一半(圓周角與圓心角在弦的同側)。

2、如果一條弧的長是另一條弧的2倍,那麼其所對的圓周角和圓心角是另一條弧的2倍。

3、圓O中的弦PQ的中點M,過點M任作兩弦AB,CD,弦AD與BC分別交PQ於X,Y,則M為XY之中點。

⑷ 用c語言寫畫出一個空心圓的程序,可以輸入自己隨意輸入圓心坐標和半徑的。謝謝!

給你個思想,首先指定圓心和半徑,園周上的點與角度是服從y=sin(a),x=cos(a)正反弦函數關系的,依次規則可以從0到2派逐點將圓畫出來。或者分別制定x軸或y軸的半徑的起始點根據x的平方+y的平方=半徑的公式對應的確定y和x再一次地畫出正負的點。

⑸ c語言畫圓 已知半徑 圓心

#include <math.h>
#include <graphics.h> /*預定義庫函數*/
void circlePoint(int x,int y) /*八分法畫圓程序*/
{
circle(320+x*20,240+y*20,3);
circle(320+y*20,240+x*20,3);
circle(320-y*20,240+x*20,3);
circle(320-x*20,240+y*20,3);
circle(320-x*20,240+y*20,3);
circle(320-x*20,240-y*20,3);
circle(320-y*20,240-x*20,3);
circle(320+y*20,240-x*20,3);
circle(320+x*20,240-y*20,3);
}
void MidBresenhamcircle(int r) /* 中點Bresenham演算法畫圓的程序 */
{
int x,y,d;
x=0;y=r;d=1-r; /* 計算初始值 */
while(x<y)
{ circlePoint(x,y); /* 繪制點(x,y)及其在八分圓中的另外7個對稱點 */
if(d<0) d+=2*x+3; /* 根據誤差項d的判斷,決定非最大位移方向上是走還是不走 */
else
{ d+=2*(x-y)+5;
y--;
}
x++;
delay(900000);
} /* while */
}
main()
{
int i,j,r,graphmode,graphdriver;
detectgraph(&graphdriver,&graphmode);
initgraph(&graphdriver,&graphmode," ");
printf("中點Bresenhamcircle演算法畫圓的程序\n"); /*提示信息*/
printf("注意 |r|<=11");
printf("\n輸入半徑值 r:");
scanf("%d",&r);
printf("按任意鍵顯示圖形...");
getch();
cleardevice();
setbkcolor(BLACK);
for(i=20;i<=620;i+=20) /*使用雙循環畫點函數畫出表格中的縱坐標*/
for(j=20;j<=460;j++)
putpixel(i,j,2);
for(j=20;j<=460;j+=20) &n歡迎光臨學網,收藏本篇文章 [1] [2]

$False$

bsp; /*使用雙循環畫點函數畫出表格中的橫坐標*/
for(i=20;i<=620;i++)
putpixel(i,j,2);
outtextxy(320,245,"0"); /*原點坐標*/
outtextxy(320-5*20,245,"-5");circle(320-5*20,240,2); /*橫坐標值*/
outtextxy(320+5*20,245,"5");circle(320+5*20,240,2);
outtextxy(320-10*20,245,"-10");circle(320-10*20,240,2);
outtextxy(320+10*20,245,"10");circle(320+10*20,240,2);
outtextxy(320-15*20,245,"-15");circle(320-15*20,240,2);
outtextxy(320+15*20,245,"15");circle(320+15*20,240,2);
outtextxy(320,240-5*20,"-5");circle(320,240-5*20,2); /*縱坐標值*/
outtextxy(320,240+5*20,"5");circle(320,240+5*20,2);
outtextxy(320,240-10*20,"-10");circle(320,240-10*20,2);
outtextxy(320,240+10*20,"10");circle(320,240+10*20,2);
outtextxy(20,10,"The center of the circle is (0,0) "); /*坐標軸左上角顯示提示信息*/
setcolor(RED); /*標記坐標軸*/
line(20,240,620,240); outtextxy(320+15*20,230,"X");
line(320,20,320,460); outtextxy(330,20,"Y");
setcolor(YELLOW);
MidBresenhamcircle(r);
setcolor(BLUE); /*繪制圓*/
circle(320,240,r*20);
setcolor(2);
getch();
closegraph();
}

⑹ C語言程序編寫 輸入圓半徑(5)和圓心角(60°),輸出圓的周長,面積和扇形周長面積。

#include <stdio.h>

double cl(float x)
{
return (2*3.14* x);
}
double cs(float x)
{
return (3.14* x* x);
}
double sl(float x, float y)
{
return (2* x+ 2* 3.14* x* y /360);
}
double ss(float x, float y)
{
return (3.14* x* x *y/ 360);
}

int main()
{
float r,ca; //r半徑,ca圓心角
printf("請輸入圓半徑:\n");
scanf("%f",&r);
printf("請輸入圓心角:\n");
scanf("%f",&ca);
printf("圓周長=%lf\t",cl(r));
printf("圓面積=%lf\n",cs(r));
printf("扇形周長=%lf\t",sl(r,ca));
printf("扇形面積=%lf\n",ss(r,ca));
}

⑺ c語言給出半徑圓心求圓上的點

#include<stdio.h>

#include<math.h>

int main()

{

double r,a,b,x1,y1;

int i;//將循環變數設置為整型

printf("請輸入圓心坐標與半徑:");

scanf("%lf,%lf,%lf",&a,&b,&r);//圓心和半徑是double型用%lf接收,注意輸入格式,數與數之間用英文逗號隔開

for(i=1;i<=360;i++)

{

x1=a+r*cos(i*3.141592/180);//"/"兩邊除數和被除數都為整型則結果為整型影響最後結果

y1=a+r*sin(i*3.141592/180);

printf("(%lf,%lf) ",x1,y1);//輸出依然用%lf

}

return 0;

}


⑻ C語言:通過輸入扇形半徑和圓心角度數求扇形面積和弧長

#include <stdio.h>
int main(){
float s,l,a,r;
printf("請輸入扇形半徑r和圓心角a(r,a):");
scanf("%f,%f",&r,&a);
s=0.5*a*r*r;
l=a*r;
printf("s=%.2f,l=%.2f\n",s,l);
return 0;
}

⑼ c語言,定義一個結構體,輸入圓心和半徑,輸出面積

不知道樓主輸入圓心干什麼,面積直接用
π*r*r就可以了,下面是一種實現辦法,不知道對你有沒有幫助:
#include<stdio.h>
#define PI 3.14159
struct area_out
{
float r;
float area;
};
int main()
{
struct area_out a;
printf("請輸入半徑r:\n");
scanf("%f",&a.r);
a.area=PI*a.r*a.r;
printf("area=%.2f\n",a.area);
return 0;
}