c++第2次作业

时间:2021-02-15 21:55:32
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double x1,y1,x2,y2;
	double d;
	double m,n;
	cout<<"请输入两点坐标:";
	cin>>x1>>y1>>x2>>y2;
	m=x1-x2;
	n=y1-y2;
	d=sqrt(m*m+n*n);
	cout<<"两点间的距离为:"<<d<<endl;
	return 0;
}
#include<iostream>  
using namespace std;;  
int main()  
{  
    int x=0,y=0;  
cin>>x;  
if(x>=1)  y=x-1;  
else     y=-x+1;  
cout<<y;  
return 0;  
}