啊啊啊又错了

P1104 生日

xuanmangguo @ 2024-10-23 19:50:58

#include<bits/stdc++.h>
using namespace std;
int a[101];
string str[101];
int main() {
    int n;cin>>n;
    int x,y,z;
    for(int i=1;i<=n;i++) {
        cin>>str[i]>>x>>y>>z;
        a[i]=x*10000+y*100+z;
    }
    for(int i=1;i<=n;i++) {
        if(a[i]>a[i+1]) {swap(str[i],str[i+1]);swap(a[i],a[i+1]);}
    }
    for(int i=1;i<=n;i++) cout<<str[i]<<endl;
    return 0;
}

by liusimo0727 @ 2024-10-23 19:57:13

样例过不了,输出不了最后一个


by liusimo0727 @ 2024-10-23 19:58:07

@xuanmangguo


by liusimo0727 @ 2024-10-23 20:02:00

#include<bits/stdc++.h>
using namespace std;
int a[101];
string str[101];
int main() {
    int n;cin>>n;
    int x,y,z;
    for(int i=1;i<=n;i++) {
        cin>>str[i]>>x>>y>>z;
        a[i]=x*10000+y*100+z;
    }
    for(int i=1;i<=n;i++) {
        if(a[i]>a[i+1]) {swap(str[i],str[i+1]);swap(a[i],a[i+1]);}
    }
    for(int i=1;i<=n+2;i++) {
        cout<<str[i];
        if (str[i]!="")
        cout<<endl;
    }
    return 0;
}

by peijun714 @ 2024-10-23 20:02:25

生日一样的要按输入顺序输出


by liusimo0727 @ 2024-10-23 20:05:27

我这个不对


|