C++实验答案(全)

实验1.1

#include \#include \void main() {

int x; cin>>x; int y; y=x*x;

cout<<\}

实验1.2

#include \void main() {

float x=1,y=2,h=3,s; s=h*(x+y)/2.0;

cout<<\上底为1,下底为2,高为3的梯形面积为:\}

实验1.3

#include \void main() {

float x,y,z,s;

cout<<\请输入三门成绩x,y,z:\ cin>>x>>y>>z; s=(x+y+z)/3;

cout<<\三门课平均成绩为:\}

实验2.1

#include \#include \void main() {

float s1,s2,s3; double aver;

cout<<\输入三个数据:\ cin>>s1>>s2>>s3; aver=(s1+s2+s3)/3; aver=aver*100+0.5; aver=(int)aver; aver=aver/100;

cout<<\平均值=\}

实验2.2

#include \#include \void main() {

double x,y,z;

cout<<\请输入直角三角形的两直角边长:\ cin>>x>>y;

z=sqrt(x*x+y*y);

cout<<\该直角三角形的斜边长为:\}

实验2.3

#include \void main() {

double x,y,r,t;

cout<<\请输入x y\cin>>x>>y; r=x*x+y*y;

if (r<=16 && r>=4) t=12*3.1415926; else t=0;

cout<

实验2.4

#include \void main() {

double a,b,c,t,ave;

cout<<\请输入三个数\cin>>a>>b>>c; if (a

ave=(a+b+c)/3;

cout<<\三个数的平均值为\,其中最小的数为:\}

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4