怎么计算任意矩形交圆形面积_C ++程序根据用户的选择来计算圆形,矩形或三角形的面积...
本文共 1304 字,大约阅读时间需要 4 分钟。
怎么计算任意矩形交圆形面积
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr(); //to clear the screen
float a,b,c,s,r,area;
int ch;
cout<<“***Menu***n1.Area of circlen2.Area of Rectangle”;
cout<<“n3.Area of trianglenEnter your choice:”;
cin>>ch;
switch(ch)
{
case 1:
{
cout<<“nEnter radius of the circle:”;
cin>>r;
area=3.14*r*r;
break;
}
case 2:
{
cout<<“nEnter length and breadth:”;
cin>>a>>b;
area=a*b;
break;
}
case 3:
{
cout<<“nEnter three sides of the triangle:”;
cin>>a>>b>>c;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
break;
}
default: cout<<“nWrong choice…!!!”;
break;
}
cout<<“Area=”<<area;
getch(); //to stop the screen
}
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr(); //to clear the screen
float a,b,c,s,r,area;
int ch;
cout<<“***Menu***n1.Area of circlen2.Area of Rectangle”;
cout<<“n3.Area of trianglenEnter your choice:”;
cin>>ch;
switch(ch)
{
case 1:
{
cout<<“nEnter radius of the circle:”;
cin>>r;
area=3.14*r*r;
break;
}
case 2:
{
cout<<“nEnter length and breadth:”;
cin>>a>>b;
area=a*b;
break;
}
case 3:
{
cout<<“nEnter three sides of the triangle:”;
cin>>a>>b>>c;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
break;
}
default: cout<<“nWrong choice…!!!”;
break;
}
cout<<“Area=”<<area;
getch(); //to stop the screen
}
翻译自:
怎么计算任意矩形交圆形面积
转载地址:http://srwwd.baihongyu.com/