虽然不是难如登天,但还是易如反掌
2024-06-01 16:21:37
发布于:广东
34阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int maxn = 1e9+1;
struct node{
string s;
int shili;
}a[100005];
bool cmp(node a, node b){
return a.shili > b.shili;
}
int get_(string s){
int i;
for(i = 1; s[i - 1] != ':'; i++);
int x = 0, f = 1;
for(; s[i] != '\0'; i++){
if(s[i] == 'm') return maxn++;
if(s[i] == '-') f = -f;
else x = x * 10 + s[i] - '0';
}return x * f;
}
bool print(string s){
int i;
for(i = 0; s[i] != ':'; i++) cout << s[i];
cout << ':';
if(s[i + 1] == 'm'){
cout << "max++\n";
return 1;
}return 0;
}
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].s;
a[i].shili = get_(a[i].s);
}sort(a + 1, a + n + 1, cmp);
for(int i = 1; i <= n; i++){
if(!print(a[i].s)) cout << a[i].shili << endl;
}
}
全部评论 2
易如反掌
2024-07-29 来自 广东
0什金1m玩牛魔
2024-06-01 来自 广东
0
有帮助,赞一个