rqnoj 126 :: 奖学金

快排都没用。。明天奔芜湖去,后天NOIp,仅仅是练手。。

 

Win底下有点奇怪

所以用的Emacs

很久以前模这个很熟,太熟了。。基本不离键盘无限顺畅。。

现在用却很不习惯了。。

习惯K&R风格,自动缩进啥的

 

#include <stdio.h>

long sum[301], chn[301], num[301], n;

void read_in()
{
long i, c, m, e;
scanf (
"%ld", &n );
for ( i = 0; i < n; i ++ ){
scanf (
"%ld %ld %ld", &c, &m, &e );
sum[i]
= c+m+e;
chn[i]
= c;
num[i]
= i+1;
}
}

void swap( long *a, long *b )
{
long tmp;
tmp
= *a;
*a = *b;
*b = tmp;
}

int main()
{
long i, j;
read_in();

for ( i = 0; i < n-1; i ++ )
for ( j = i+1; j < n; j ++ )
if ( sum[i] < sum[j] || (sum[i]==sum[j] && chn[i]<chn[j]) ||
(sum[i]
==sum[j] && chn[i]==chn[j] && num[i]>num[j]) ){
swap (
&sum[i], &sum[j] );
swap (
&chn[i], &chn[j] );
swap (
&num[i], &num[j] );
}

for ( i = 0; i < 5; i ++ )
printf (
"%ld %ld\n", num[i], sum[i] );
return 0;
}

 

posted on 2010-11-18 22:53  Jasper Ho  阅读(201)  评论(0编辑  收藏  举报

导航