ACM小题,错哪儿
ACM小题,错哪里?
------解决方案--------------------
开根号是sqrt.
#include <iostream>
using namespace std;
int main()
{
float x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
float s=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
cout.precision(2);
cout<<fixed<<s<<endl;
return 0;
}
------解决方案--------------------
开根号是sqrt.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
float s=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
s = sqrt(s);
cout.precision(2);
cout<<fixed<<s<<endl;
return 0;
}