帮我看下代码哪里有问题并请改正,是用构造结构 体,运算符重载>号的方法做的,这其实就是pair的底层算法原理,谢谢!
题目:

我的代码:
#include<bits/stdc++.h>
using namespace std;
int n,sum;
struct fufu {
int h;
int w;
bool operator>(fufu other) {
if (h != other.h) {
return h > other.h;
}
else {
return w > other.w;
}
}
};
int main() {
cin >> n;
fufu s[100];
for (int i = 1; i <= n; i++) {
cin >> s[i].h >> s[i].w;
}
for (int i = 1; i <= n - 1; i++) {
for (int j = 1; j <= n - i; j++) {
if (s[j] > s[j + 1]) {
swap(s[j], s[j + 1]);
sum++;
}
}
}
cout <<sum<< endl;
return 0;
}
请大家帮帮忙吧!Thanks~~
