题解

158 条题解

  • 0
    @ 2008-07-25 15:25:26

    咳,原题。兴趣都没有。

  • 0
    @ 2008-07-25 12:52:30

    直接在提交上打,都没编译,其结果是WA了两次,到第三次才AC。

  • 0
    @ 2008-07-25 10:10:20

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 06:运行时错误...|错误号: -1073741571

    ├ 测试数据 07:运行时错误...|错误号: -1073741571

    ├ 测试数据 08:运行时错误...|错误号: -1073741571

    ├ 测试数据 09:运行时错误...|错误号: -1073741571

    ├ 测试数据 10:答案正确... 0ms

  • 0
    @ 2008-07-24 21:42:54

    水题,同意3楼,...................地下室的地下室

  • 0
    @ 2008-07-24 21:41:26

    严重同意!!!!!!!!!!

  • 0
    @ 2008-07-24 21:17:37

    直接打代码………………

  • -1
    @ 2020-04-11 18:33:18
    #include <iostream>             //[2007普及组-A]奖学金
    #include <algorithm>
    using namespace std;
    
    struct Student{
        int code;   //学号
        int total;  //总成绩
        int yu; //语文成绩
    } S[300];
    
    bool cmp(Student a, Student b)
    {
        if(a.total == b.total)
        {
            if(a.yu == b.yu)
                return a.code < b.code;
            return a.yu > b.yu;
        }
        return a.total > b.total;
    }
    int main()
    {
        int n, yu, math, Eng;
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            cin >> yu >> math >> Eng;
            S[i].code = i + 1;
            S[i].yu = yu;
            S[i].total = yu + math + Eng;
        }
        sort(S, S + n, cmp);
    
        for (int i = 0; i < 5; i++)
            cout << S[i].code << " " << S[i].total << endl;
    
        return 0;
    }
    
    
  • -1
    @ 2018-01-31 16:03:41

    #include<bits/stdc++.h>
    using namespace std;
    struct stu
    {
    int math,chi,eng,mark,num;
    }stu[1000],t;
    int main()
    {
    int i,j,n;

    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>stu[i].chi>>stu[i].math>>stu[i].eng;
    stu[i].mark=stu[i].chi+stu[i].math+stu[i].eng;
    stu[i].num=i;
    }
    for(j=1;j<n;j++)
    for(i=1;i<=n-j;i++)
    {
    if(stu[i].mark<stu[i+1].mark)
    {
    t=stu[i];
    stu[i]=stu[i+1];
    stu[i+1]=t;
    }
    if(stu[i].mark==stu[i+1].mark&&stu[i].chi<stu[i+1].chi)
    {
    t=stu[i];
    stu[i]=stu[i+1];
    stu[i+1]=t;
    }

    }
    for(i=1;i<=5;i++)
    {
    cout<<stu[i].num<<" "<<stu[i].mark<<endl;
    }
    return 0;
    }

  • -1
    @ 2018-01-31 16:03:33

    #include<bits/stdc++.h>
    using namespace std;
    struct stu
    {
    int math,chi,eng,mark,num;
    }stu[1000],t;
    int main()
    {
    int i,j,n;

    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>stu[i].chi>>stu[i].math>>stu[i].eng;
    stu[i].mark=stu[i].chi+stu[i].math+stu[i].eng;
    stu[i].num=i;
    }
    for(j=1;j<n;j++)
    for(i=1;i<=n-j;i++)
    {
    if(stu[i].mark<stu[i+1].mark)
    {
    t=stu[i];
    stu[i]=stu[i+1];
    stu[i+1]=t;
    }
    if(stu[i].mark==stu[i+1].mark&&stu[i].chi<stu[i+1].chi)
    {
    t=stu[i];
    stu[i]=stu[i+1];
    stu[i+1]=t;
    }

    }
    for(i=1;i<=5;i++)
    {
    cout<<stu[i].num<<" "<<stu[i].mark<<endl;
    }
    return 0;
    }

  • -1
    @ 2018-01-31 16:03:11

    #include<bits/stdc++.h>
    using namespace std;
    struct stu
    {
    int math,chi,eng,mark,num;
    }stu[1000],t;
    int main()
    {
    int i,j,n;

    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>stu[i].chi>>stu[i].math>>stu[i].eng;
    stu[i].mark=stu[i].chi+stu[i].math+stu[i].eng;
    stu[i].num=i;
    }
    for(j=1;j<n;j++)
    for(i=1;i<=n-j;i++)
    {
    if(stu[i].mark<stu[i+1].mark)
    {
    t=stu[i];
    stu[i]=stu[i+1];
    stu[i+1]=t;
    }
    if(stu[i].mark==stu[i+1].mark&&stu[i].chi<stu[i+1].chi)
    {
    t=stu[i];
    stu[i]=stu[i+1];
    stu[i+1]=t;
    }

    }
    for(i=1;i<=5;i++)
    {
    cout<<stu[i].num<<" "<<stu[i].mark<<endl;
    }
    return 0;
    }

  • -1
    @ 2018-01-21 16:20:21

    #include<cstdio>
    #include<algorithm>//STL的头文件
    using namespace std;//STL的头文件
    struct nod{int id,ma,f;}a[310];

    bool cmp(nod x,nod y)
    {
    if(x.ma!=y.ma)return x.ma>y.ma; //如果总分不相等
    if(x.f!=y.f)return x.f>y.f; //如果语文成绩不相等
    else return x.id<y.id;
    //说明:return x>y;的意思是如果x>y,就rteurn true,否则return false;
    }

    int main()
    {
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    int x,b,c;scanf("%d %d %d",&x,&b,&c);
    a[i].ma=x+b+c;
    a[i].id=i;a[i].f=x;
    }//如果输入不会我也没办法了
    sort(a+1,a+n+1,cmp);//c++自带动快排,cmp是判断是否交换的函数
    for(int i=1;i<=5;i++)printf("%d %d\n",a[i].id,a[i].ma);
    }

  • -1
    @ 2018-01-21 16:19:46

    #include<cstdio>
    #include<algorithm>//STL的头文件
    using namespace std;//STL的头文件
    struct nod{int id,ma,f;}a[310];

    bool cmp(nod x,nod y)
    {
    if(x.ma!=y.ma)return x.ma>y.ma; //如果总分不相等
    if(x.f!=y.f)return x.f>y.f; //如果语文成绩不相等
    else return x.id<y.id;
    //说明:return x>y;的意思是如果x>y,就rteurn true,否则return false;
    }

    int main()
    {
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    int x,b,c;scanf("%d %d %d",&x,&b,&c);
    a[i].ma=x+b+c;
    a[i].id=i;a[i].f=x;
    }//如果输入不会我也没办法了
    sort(a+1,a+n+1,cmp);//c++自带动快排,cmp是判断是否交换的函数
    for(int i=1;i<=5;i++)printf("%d %d\n",a[i].id,a[i].ma);
    }

  • -1
    @ 2017-10-09 18:57:39

    #include<iostream>

    using namespace std;

    struct tStudent
    {
    int yuwen,
    shuxue,
    yingyu,
    total,
    num;
    };
    int main()
    {
    tStudent p[301];
    int a,temp,temp2,k,j,temp3;
    cin>>a;
    for(int i=0;i<a;i++)
    {
    cin>>p[i].yuwen>>p[i].shuxue>>p[i].yingyu;
    p[i].num=i+1;
    }
    for(int i=0;i<=a;i++)
    p[i].total=p[i].yuwen+p[i].shuxue+p[i].yingyu;
    for(int i=0;i<a;i++)
    {
    k=i;
    for(j=i+1;j<a;j++)
    if(p[k].total>p[j].total)
    k=j;
    if(k!=i)
    {
    temp=p[k].total;
    p[k].total=p[i].total;
    p[i].total=temp;
    temp2=p[k].num;
    p[k].num=p[i].num;
    p[i].num=temp2;
    temp3=p[k].yuwen;
    p[k].yuwen=p[i].yuwen;
    p[i].yuwen=temp3;
    }
    }
    for(int i=a-1;i>a-6;i--)
    for(int x=i-1;x>a-6;x--)
    if(p[i].total==p[x].total)
    if(p[i].yuwen>p[x].yuwen)
    {
    temp=p[i].total;
    p[i].total=p[x].total;
    p[x].total=temp;
    temp2=p[i].num;
    p[i].num=p[x].num;
    p[x].num=temp2;
    }
    for(int i=a-1;i>a-6;i--)
    cout<<p[i].num<<" "<<p[i].total<<endl;
    return 0;
    }

  • -1
    @ 2017-08-22 02:38:36

    so water

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    
    int main(){
        int n,i,j,a[350],b[350],c[350],a2,x,y,z;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%d %d %d",&x,&y,&z);
            a[i]=x+y+z;
            b[i]=x;
            c[i]=i;
        }
        for(i=1;i<=n-1;i++)
        {
            for(j=1;j<=n-i;j++)
            {
                if(a[j]<a[j+1])
                {
                    a2=a[j];
                    a[j]=a[j+1];
                    a[j+1]=a2;
                    a2=b[j];
                    b[j]=b[j+1];
                    b[j+1]=a2;
                    a2=c[j];
                    c[j]=c[j+1];
                    c[j+1]=a2;
                }
                else if(a[j]==a[j+1])
                {
                    if(b[j]<b[j+1])
                    {
                        a2=b[j];
                        b[j]=b[j+1];
                        b[j+1]=a2;
                        a2=c[j];
                        c[j]=c[j+1];
                        c[j+1]=a2;
                    }
                    else if(b[j]==b[j+1])
                    {
                        if(c[j]>c[j+1])
                        {
                            a2=c[j];
                            c[j]=c[j+1];
                            c[j+1]=a2;
                        }
                    }
                }
            }
        }
        for(i=1;i<=5;i++)
        {
            printf("%d %d\n",c[i],a[i]);
        }
        return 0;
    }
    
  • -1
    @ 2017-03-15 17:00:50

    var
    a,b,c,d,s:array[1..100000] of longint;
    t,i,j,n:longint;
    procedure qw();
    begin
    t:=s[i]; s[i]:=s[j]; s[j]:=t;
    t:=a[i]; a[i]:=a[j]; a[j]:=t;
    t:=b[i]; b[i]:=b[j]; b[j]:=t;
    t:=c[i]; c[i]:=c[j]; c[j]:=t;
    t:=d[i]; d[i]:=d[j]; d[j]:=t;
    end;
    begin
    readln(n);
    for i:=1 to n do begin
    readln(a[i],b[i],c[i]);
    s[i]:=a[i]+b[i]+c[i];
    d[i]:=i;
    end;
    for i:=1 to n-1 do begin
    for j:=i+1 to n do begin
    if s[i]<s[j] then qw;
    if s[i]=s[j] then begin
    if a[i]<a[j] then qw;
    if a[i]=a[j] then begin
    if d[i]>d[j] then qw;
    end;
    end;
    end;
    end;
    for i:=1 to 5 do begin
    writeln(d[i],' ',s[i]);
    end;
    end.

  • -1
    @ 2017-03-15 17:00:50

    var
    a,b,c,d,s:array[1..100000] of longint;
    t,i,j,n:longint;
    procedure qw();
    begin
    t:=s[i]; s[i]:=s[j]; s[j]:=t;
    t:=a[i]; a[i]:=a[j]; a[j]:=t;
    t:=b[i]; b[i]:=b[j]; b[j]:=t;
    t:=c[i]; c[i]:=c[j]; c[j]:=t;
    t:=d[i]; d[i]:=d[j]; d[j]:=t;
    end;
    begin
    readln(n);
    for i:=1 to n do begin
    readln(a[i],b[i],c[i]);
    s[i]:=a[i]+b[i]+c[i];
    d[i]:=i;
    end;
    for i:=1 to n-1 do begin
    for j:=i+1 to n do begin
    if s[i]<s[j] then qw;
    if s[i]=s[j] then begin
    if a[i]<a[j] then qw;
    if a[i]=a[j] then begin
    if d[i]>d[j] then qw;
    end;
    end;
    end;
    end;
    for i:=1 to 5 do begin
    writeln(d[i],' ',s[i]);
    end;
    end.

  • -1
    @ 2016-12-04 13:34:11

    AC留作纪念
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define maxa 310
    using namespace std;
    struct Node
    {
    int cnt;
    int a,b,c;
    int sum;
    }p[maxa];
    bool comp(Node s,Node t)
    {
    if(s.sum>t.sum)
    return true;
    else if(s.sum==t.sum)
    {
    if(s.a>t.a)
    return true;
    else if(s.a==t.a)
    {
    if(s.cnt<t.cnt)
    return true;
    }
    }
    return false;
    }
    int main()
    {
    int n,i;
    cin>>n;
    for(i=0;i<n;++i)
    {
    cin>>p[i].a>>p[i].b>>p[i].c;
    p[i].cnt = i+1;
    p[i].sum = p[i].a+p[i].b+p[i].c;
    }
    sort(p,p+n,comp);
    for(i=0;i<5;++i)
    {
    cout<<p[i].cnt<<" "<<p[i].sum<<endl;
    }
    return 0;
    }

  • -1
    @ 2016-11-17 05:11:43

    #include <iostream>
    #include <cmath>
    #include <string.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <climits>

    #include <algorithm>

    using namespace std;

    struct stu
    {
    int num;
    int chinese;
    int math;
    int english;
    int sum;
    };

    bool uu(const stu &x, const stu &y)
    {
    if(x.sum != y.sum)
    return x.sum>y.sum;
    else if(x.chinese != y.chinese)
    return x.chinese>y.chinese;
    else return x.num<y.num;
    }

    int main()
    {
    stu a[301];

    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
    {
    a[i].num=i;
    cin>>a[i].chinese>>a[i].math>>a[i].english;
    a[i].sum=a[i].chinese+a[i].math+a[i].english;
    }

    sort(a+1,a+1+n,uu);

    for(int i=1;i<=5;i++)
    {
    cout<<a[i].num<<' '<<a[i].sum<<endl;
    }

    return 0;
    }

  • -1
    @ 2016-08-27 23:28:30

    #include <iostream>
    #include <vector>
    #include <cstring>

    using namespace std;

    struct student//学生信息
    {
    int cord;
    int ch;
    int ma;
    int en;
    int add;
    void cls()
    {
    cord = 0;
    ch = 0;
    ma = 0;
    en = 0;
    add = 0;
    return;
    }
    }cla[301];

    void swap(int l,int r)//交换
    {
    struct student temp;
    temp.cls();

    temp.cord=cla[l].cord;
    temp.add=cla[l].add;
    temp.ch=cla[l].ch;

    temp.ma=cla[l].ma;
    temp.en=cla[l].en;

    cla[l].cord=cla[r].cord;
    cla[l].add=cla[r].add;
    cla[l].ch=cla[r].ch;

    cla[l].ma=cla[r].ma;
    cla[l].en=cla[r].en;

    cla[r].cord=temp.cord;
    cla[r].add=temp.add;
    cla[r].ch=temp.ch;

    cla[r].ma=temp.ma;
    cla[r].en=temp.en;
    }

    void ksort(int l,int r)//快排总分
    {
    int mid=cla[(l+r)/2].add;
    int i=l,j=r;
    do
    {
    while(cla[i].add>mid)++i;
    while(cla[j].add<mid)--j;
    if(i<=j)
    {
    swap(i,j);
    ++i;
    --j;
    }
    }while(i<=j);
    if(l<j)ksort(l,j);
    if(i<r)ksort(i,r);
    return;
    }

    void ksort2(int l,int r)//快排语文
    {
    int mid=cla[(l+r)/2].ch;
    int i=l,j=r;
    do
    {
    while(cla[i].ch>mid)++i;
    while(cla[j].ch<mid)--j;
    if(i<=j)
    {
    swap(i,j);
    ++i;
    --j;
    }
    }while(i<=j);
    if(l<j)ksort2(l,j);
    if(i<r)ksort2(i,r);
    return;
    }

    void ksort3(int l,int r)//快排学号
    {
    int mid=cla[(l+r)/2].cord;
    int i=l,j=r;
    do
    {
    while(cla[i].cord<mid)++i;
    while(cla[j].cord>mid)--j;
    if(i<=j)
    {
    swap(i,j);
    ++i;
    --j;
    }
    }while(i<=j);
    if(l<j)ksort3(l,j);
    if(i<r)ksort3(i,r);
    return;
    }

    void print(int i)//输出第i个学生信息
    {
    cout<<cla[i].cord<<' '<<cla[i].add<<endl;
    }

    int main()
    {
    int n;
    int i;
    for( i = 0 ; i < 301 ; ++i )//结构体初始化
    cla[i].cls();
    cin >> n;
    for( i = 1 ; i <= n; ++i )//输入
    {
    cla[i].cord = i;
    cin >> cla[i].ch >> cla[i].ma >> cla[i].en;
    cla[i].add = cla[i].ch + cla[i].ma + cla[i].en;
    }
    ksort(1,n);//总分排序
    int l1;
    //***语文排序
    for(i=1;i<5;++i)//从i~l1的总分相同,1~5有不确定的 i~l1
    {
    l1=i;
    while(cla[i].add==cla[i+1].add)++i;
    ksort2(l1,i);
    }
    //***
    //***学号排序
    for(i=1;i<5;++i)//从i~l1的语文相同,1~5有不确定的 i~l1
    {
    l1=i;
    while(cla[i].ch==cla[i+1].ch)++i;
    ksort3(l1,i);
    }
    //***
    for(i=1;i<=5;++i)//输出
    print(i);
    return 0;
    }

  • -1
    @ 2016-08-19 16:46:02

    var
    a,b,c,d,s:array[1..100000] of longint;
    t,i,j,n:longint;
    begin
    readln(n);
    for i:=1 to n do begin
    readln(a[i],b[i],c[i]);
    s[i]:=a[i]+b[i]+c[i];
    d[i]:=i;
    end;
    for i:=1 to n-1 do begin
    for j:=i+1 to n do begin
    if s[i]<s[j] then begin
    t:=s[i]; s[i]:=s[j]; s[j]:=t;
    t:=a[i]; a[i]:=a[j]; a[j]:=t;
    t:=b[i]; b[i]:=b[j]; b[j]:=t;
    t:=c[i]; c[i]:=c[j]; c[j]:=t;
    t:=d[i]; d[i]:=d[j]; d[j]:=t;
    end;
    if s[i]=s[j] then begin
    if a[i]<a[j] then begin
    t:=s[i]; s[i]:=s[j]; s[j]:=t;
    t:=a[i]; a[i]:=a[j]; a[j]:=t;
    t:=b[i]; b[i]:=b[j]; b[j]:=t;
    t:=c[i]; c[i]:=c[j]; c[j]:=t;
    t:=d[i]; d[i]:=d[j]; d[j]:=t;
    end;
    if a[i]=a[j] then begin
    if d[i]>d[j] then begin
    t:=s[i]; s[i]:=s[j]; s[j]:=t;
    t:=a[i]; a[i]:=a[j]; a[j]:=t;
    t:=b[i]; b[i]:=b[j]; b[j]:=t;
    t:=c[i]; c[i]:=c[j]; c[j]:=t;
    t:=d[i]; d[i]:=d[j]; d[j]:=t;
    end;
    end;
    end;
    end;
    end;
    for i:=1 to 5 do begin
    writeln(d[i],' ',s[i]);
    end;
    end.

信息

ID
1398
难度
4
分类
其他 | 排序 点击显示
标签
递交数
6456
已通过
2669
通过率
41%
被复制
23
上传者