题解 | #正方形检测#
正方形检测
https://ac.nowcoder.com/acm/problem/21842
include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=10010;
int x[6];
int y[6];
int main(){
vector<int>vt;
scanf("%d %d %d %d\n",&x[1],&x[2],&x[3],&x[4]);
scanf("%d %d %d %d\n",&y[1],&y[2],&y[3],&y[4]);
for(int i=1;i<=3;i++){
for(int j=i+1;j<=4;j++){
vt.push_back(abs((x[i]-x[j])(x[i]-x[j])+(y[i]-y[j])(y[i]-y[j])));
}
}
int a=INT_MAX;
for(int i=0;i<vt.size();i++){
a=min(a,vt[i]);
}
for(int i=0;i<vt.size();i++){
if(vt[i]!=a&&vt[i]!=2*a){
cout<<"Not a square"<<endl;
return 0;
}
}
cout<<"It's a square"<<endl;
return 0;
}</int>