一、分级函数求值
# include <iostream>
using namespace std;
int main()
{
int x,y;
cout<<"请输入x"<<endl;
cin>>x;
if(x>=1)
y=x-1;
else
y=1-x;
cout<<y;
return 0;
}
二、两点距离
# include<cmath>
# include <iostream>
using namespace std;
int main()
{
double x1,y1,x2,y2,d;
cout<<"请输入两点坐标"<<endl;
cin>>x1>>y1>>x2>>y2;
d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
cout<<d<<endl;
return 0;
}