您的位置:首页 > 编程语言 > C语言/C++

C++作业2

2016-03-24 09:26 267 查看
#include <iostream>

using namespace std;

int main()

{

double height,weight,a;

cout<<"请输入身高=";

cin>>height;

cout<<"请输入体重=";

cin>>weight;

a=height-100;

if (weight>1.2*a)

cout<<"超重";

if (weight<0.8*a)

cout<<"超轻";

else

cout<<"标准";

return 0;

}

#include<iostream>

using namespace std;

int main()

{

int x,y;

cout<<"请输入整数x:";

cin>>x;

if(x>=1)

y=x-1;

else if(x<1)

y=1-x;

cout<<y<<endl;

return 0;

}

#include<iostream.h>

#include<math.h>

void main()

{

double x1,y1,x2,y2,a,b,c;

cout<<"请输入第一个点的坐标:";

cin>>x1>>y1;

cout<<"请输入第二个点的坐标:";

cin>>x2>>y2;

a=(x1-x2)*(x1-x2);

b=(y1-y2)*(y1-y2);

c=sqrt(a+b);

cout<<c<<endl;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: