这个代码为什么60pts啊?
查看原帖
这个代码为什么60pts啊?
176843
Scarab楼主2020/5/24 18:34
#include<bits/stdc++.h>
using namespace std;

struct SOS {
	int data;
	string sos, name;
}a[105];

int n;

bool cmp (SOS a, SOS b) {
	return a.data > b.data;
}

int main() {
//	freopen("save.in","r",stdin);
//	freopen("save.out","w",stdout);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].name >> a[i].sos;
		for (int j = 0; j < a[i].sos.size(); ++j) {
			if (a[i].sos[j] == 's' && a[i].sos[j + 1] == 'o' && a[i].sos[j + 2] == 's') ++a[i].data;
		}
	}
	sort(a + 1, a + 1 + n, cmp);
	int maxn = a[1].data;
	for (int i = 1; i <= n; ++i) {
		if (a[i].data == maxn) cout << a[i].name << " ";
	}
	cout << endl;
	cout << maxn << endl;
	return 0;
}

自我感觉没错啊

2020/5/24 18:34
加载中...