『壹』 編寫:輸入圓錐體的半徑r,和高h,計算圓錐體的面積.的c語言程序
#include<math.h>sqrt
int main()
{
double r,h;
scanf("%lf", &r);
scanf("%lf", &h);
//s1是側面積 = π*r*l 其中l是母線 l=sqrt(r*r+h*h)
//s2是底面積 =π*r*r
double s1= 3.14* r* sqrt(r*r+h*h);
double s2= 3.14* r*r;
printf("%lf", s1+s1);
return 0;
}
『貳』 用C語言 編輯一個求圓錐體表面積與體積的代碼
我來回答#include<iostream>
#include<cmath>
#define N 3.1415
using namespace std;
class Height
{
private:
float h;
public:
Height(float h):h(h)
{}
float getheight()
{
return h;
}
};
class Circle
{
private:
float radius;
public:
Circle(float r):radius(r)
{}
float getradius();
float area();
};
float Circle::getradius()
{
return radius;
}
float Circle::area()
{
return N*radius*radius;
}
class cone:public Height,public Circle
{
private:
float line;
public:
cone(float h,float r):Height(h),Circle(r)
{}
void getline();
float surarea();
float volume();
void show();
};
void cone::getline()
{
float a=getradius();
float b=getheight();
line=sqrt(a*a+b*b);
}
float cone::surarea()
{
return area()+N*getradius()*line;
}
float cone::volume()
{
return area()*getheight()/3;
}
void cone::show()
{
cout<<"圓錐的表面積為:"<<surarea()<<endl;
cout<<"圓錐的體積為:"<<volume()<<endl;
}
int
main()
{
cone A(4,3);
A.getline();
A.surarea();
A.volume();
A.show();
return 0;
}
『叄』 用c語言編寫程序,有一個圓錐體,底面半徑為r,高為h,求圓錐體的底面周長,表面積和體積。
//示例代碼
#include<stdio.h>
#include<math.h>
#definePI3.1415926
intmain()
{
floatr,h;
floatc,s,v;//底面周長,表面積,體積
scanf("%f%f",&r,&h);
c=2*PI*r;//底面周長
s=PI*r*(r+sqrt(r*r+h*h));//表面積
v=PI*(r*r)*h/3;//體積
printf("圓錐體的底面周長=%.2f ",c);
printf("圓錐體的表面積=%.2f ",s);
printf("圓錐體的體積=%.2f ",v);
return0;
}
//示例運行結果
35
圓錐體的底面周長=18.85
圓錐體的表面積=83.23
圓錐體的體積=47.12
『肆』 c語言 設計三個高數,分別求圓錐體的體積、表面積、質量。從主函數中輸入圓錐體的高和直徑,然後輸出它
double calcv(double h,double d)
{
return 3.14*d*d*h/4/3;
}
表面積和質量不會算
『伍』 用c語言求圓錐的圓面積和體積
#include<iostream>
#include<cmath>
#define N 3.1415
using
namespace std;
class Height
{
private:
float
h;
public:
Height(float h):h(h)
{}
float getheight()
{
return
h;
}
};
class Circle
{
private:
float
radius;
public:
Circle(float r):radius(r)
{}
float
getradius();
float area();
};
float
Circle::getradius()
{
return radius;
}
float
Circle::area()
{
return N*radius*radius;
}
class cone:public
Height,public Circle
{
private:
float line;
public:
cone(float
h,float r):Height(h),Circle(r)
{}
void getline();
float
surarea();
float volume();
void show();
};
void
cone::getline()
{
float a=getradius();
float
b=getheight();
line=sqrt(a*a+b*b);
}
float
cone::surarea()
{
return area()+N*getradius()*line;
}
float
cone::volume()
{
return area()*getheight()/3;
}
void
cone::show()
{
cout<<"圓錐的表面積為:"<<surarea()<<endl;
cout<<"圓錐的體積為:"<<volume()<<endl;
}
int
main()
{
cone
A(4,3);
A.getline();
A.surarea();
A.volume();
A.show();
return
0;
}
『陸』 數學:求無頂圓錐表面積,上圓直徑76,下圓直徑150,高80。咋做
無頂圓錐 就是圓台,用圓台表面積公式計算,不計入頂圓面積即可。
網頁鏈接 -- 見網路
母線長度: l=sqrt( (R-r)*(R-r)+h*h); (sqrt 是開平方)
側面積:Sc=3.14159*l*(R+r);
底面積:Sb= 3.14159*R*R;
無頂圓錐表面積:S=Sc+Sb;
c語言程序:
#include <stdio.h>
#include <math.h>
int main()
{
double r=76,R=150,h=80;
double S,Sc,Sb,l;
l=sqrt( (R-r)*(R-r)+h*h);
Sc=3.14159*l*(R+r);
Sb= 3.14159*R*R;
S = Sc+Sb;
printf("%f
",S);
return 0;
}
得:148059.417
『柒』 有關C語言:求圓錐體的體積和表面積,急!!!!!!1
#include<stdio.h>
#include <math.h>
void f1(int h,int d)
{
double v;
v=h*3.14*(d/2)*(d/2)/3;
printf("v=%lf\n",v);
}
void f2(int h,int d)
{
double s;
s=3.14*(d/2)*(d/2)+sqrt(h*h+(d/2)*(d/2))*(3.14*d/2);
printf("s=%lf\n",s);
}
int main()
{
int h,d;
printf("輸入高:\n");
scanf("%d",&h);
printf("輸入直徑:\n");
scanf("%d",&d);
f1(h,d);
f2(h,d);
return 0;
}
試試這個吧,你的代碼錯誤少了一個應用數學函數的頭文件math.h,main函數也沒有返回值類型,貌似體積公式也不對,還有就是數據類型的問題(這個代碼不會出錯,但是結果會有影響)。
『捌』 C語言入門程序,求圓錐體底面積和體積。
#include#includevoidmain(){intr,h,pi;r=2;h=3;pi=3.14;printf("圓周長=%d\n",2*pi*r);printf("圓柱底面積=%d\n",pi*r*r);printf("圓柱體積=%d\n",pi*r*r*h);}
『玖』 c語言 圓錐的高已確定為5,從鍵盤讀入圓錐的底面圓的半徑,計算並輸出圓錐的表面積和體積
#include <stdio.h>
#include <math.h>
#define pi 3.14
int main( )
{
float h=5.0,r,s,v;
printf("請輸入圓錐底面圓的半徑:\n");
scanf("%f",&r);
s=pi*r*(r+sqrt(r*r+h*h));
v=pi*r*r*h/3;
printf("s=%f,v=%f\n",s,v);
return 0;
}
『拾』 c語言問題,輸入圓錐的半徑和高,得出表面積和體積。請問程序該如何改.
首先你的程序中體積公式就錯了,你忘了除以3,要注意細節啊。還有輸出格式不應該是%d,這與你前面定義的格式不符。你的程序可修改為:
#include<stdio.h>
#include<math.h>
#define PI 3.1415927
void main()
{
double fRadius,fHeight,fSquare,fVolume;
printf("Input the radius of the cone: ");
scanf("%lf",&fRadius);
printf("Input the height of the cone: ");
scanf("%lf",&fHeight);
fSquare=PI*fRadius*(fRadius+pow(fRadius*fRadius+fHeight*fHeight,0.5));
fVolume=PI*fRadius*fRadius*fHeight/3.0;
printf("The area of the cone is %.2f ",fSquare);
printf("The volume of the cone is %.2f ",fVolume);
}