解题思路

寻找最小点(x1,y1)和最大点(x2,y2),取最大边长即为最小正方形边长;注意输入输出,简单模拟即可;

代码

#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    while(cin >> n){ //注意题目,同时输入多组数据
        int x1 = INT_MAX, y1 = INT_MAX, x2 = INT_MIN, y2 = INT_MIN;
        while(n){
            int x0, y0;
            cin >> x0 >> y0;
            x1 = min(x1, x0);
            y1 = min(y1, y0); //(x1,y1)最小点
            x2 = max(x2, x0);
            y2 = max(y2, y0); //(x2,y2)最大点
            n--;
        }
        int x = max(x2 - x1, y2 - y1);
        cout << x * x << endl;
    }
    return 0;
}