1 条题解

  • 0
    @ 2025-2-14 20:58:58

    C++ :

    #include<cstdio>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<iostream>
    using namespace std;
    struct xuhao
    {
        int a;
        string b;
    }c[1000];
    int compare(xuhao x,xuhao y)
    {
        return x.a<y.a;
    }
    int main()
    {
        int n,i;
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            cin>>c[i].a>>c[i].b;
        }
        sort(c,c+n,compare);
        for(i=0;i<n;i++)
        {
            cout<<c[i].b<<endl;;
        }
    }
    

    Pascal :

    var
      s,tmp:string;
      i,j,n:longint;
      f:array[1..1000] of longint;
      s1:array[1..1000] of string;
    begin
      readln(n);
      for i:=1 to n do
        begin
          readln(s);
          tmp:=copy(s,1,pos(' ',s)-1);
          val(tmp,f[i]);
          s1[i]:=copy(s,pos(' ',s)+1,length(s)-pos(' ',s));
        end;
      for i:=1 to 1000 do
        for j:=1 to 1000 do
          if f[j]=i then writeln(s1[j]);
    end.
    
    • 1

    信息

    ID
    569
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者