竞赛讨论区 > 我的代码只可以通过80%
头像
小鳖是龟仙人
发布于 2021-02-07 19:26
+ 关注

我的代码只可以通过80%

这个题我的代码如下
#include<stdio.h>
int main()
{
    int a[300],b[300],c[300],d[300],e[300],i,j,k,l,n,m,temp;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=1;i<n+1;i++)
        {
            scanf("%d %d %d",&a[i],&b[i],&c[i]);
            e[i]=i;
            d[i]=a[i]+b[i]+c[i];
        }
        for(i=1;i<n+1;i++)
        for(j=i+1;j<n+1;j++)
        {
            if(d[j]>d[i])
            {
                {
                    temp=d[j];
                    d[j]=d[i];
                    d[i]=temp;
                }
                {
                    temp=e[j];
                    e[j]=e[i];
                    e[i]=temp;
                }
                {
                    temp=a[j];
                    a[j]=a[i];
                    a[i]=temp;
                }
                {
                    temp=b[j];
                    b[j]=b[i];
                    b[i]=temp;
                }
                {
                    temp=c[j];
                    c[j]=c[i];
                    c[i]=temp;
                }
                
            }
            if(d[j]==d[i]&&a[i]<a[j])
            {
                    {
                    temp=d[j];
                    d[j]=d[i];
                    d[i]=temp;
                }
                {
                    temp=e[j];
                    e[j]=e[i];
                    e[i]=temp;
                }
                {
                    temp=a[j];
                    a[j]=a[i];
                    a[i]=temp;
                }
                {
                    temp=b[j];
                    b[j]=b[i];
                    b[i]=temp;
                }
                {
                    temp=c[j];
                    c[j]=c[i];
                    c[i]=temp;
                }
            }
            if(d[j]==d[i]&&a[i]==a[j]&&e[i]>e[j])
            {
                    {
                    temp=d[j];
                    d[j]=d[i];
                    d[i]=temp;
                }
                {
                    temp=e[j];
                    e[j]=e[i];
                    e[i]=temp;
                }
                {
                    temp=a[j];
                    a[j]=a[i];
                    a[i]=temp;
                }
                {
                    temp=b[j];
                    b[j]=b[i];
                    b[i]=temp;
                }
                {
                    temp=c[j];
                    c[j]=c[i];
                    c[i]=temp;
                }
            }
        }
        for(i=1;i<6;i++)
        {
            printf("%d %d\n",e[i],d[i]);
        }
            
    }
    return 0;
}
可是不知道为什么只可以过80%
希望各位大佬可以指正,xiexie

全部评论

(0) 回帖
加载中...
话题 回帖

本文相关内容

等你来战

查看全部

热门推荐