Posted on 2009-03-13 20:29
Hero 阅读(117)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 // 1129 Accepted 0 84 1147 C++
2 //简单排序
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7
8 struct NODE
9 {
10 int num ;
11 int val ;
12 };
13 struct NODE node[1000] ;
14
15 int innum ;
16 int inn, inm ;
17
18 int cmp( const void *a, const void *b )
19 {
20 struct NODE *c = (struct NODE *)a ;
21 struct NODE *d = (struct NODE *)b ;
22
23 if( c->val != d->val )
24 return d->val - c->val ;
25 else
26 return c->num - d->num ;
27 }
28
29 int main()
30 {
31 while( scanf( "%d", &innum ) != EOF && innum )
32 {
33 while( innum -- )
34 {
35 scanf( "%d %d", &inn, &inm ) ;
36
37 for( int i=1,k=1; i<=inn; i++,k++ )
38 {
39 node[i].num = k ; node[i].val = 0 ;
40 bool ispassed = true ; int val = 0 ;
41 for( int j=1; j<=inm; j++ )
42 {
43 scanf( "%d", &val ) ;
44 if( val < 60 ) ispassed = false ;
45 node[i].val += val ;
46 }
47 if( !ispassed ) { i-- ; inn-- ; }
48 }
49
50 if( 0 == inn )
51 {
52 printf( "NULL\n" );
53 }
54 else
55 {
56 qsort( node+1, inn, sizeof(node[1]), cmp ) ;
57 char *blank = "" ;
58 for( int i=1; i<=inn; i++ )
59 {
60 printf( "%s%d", blank, node[i].num ) ;
61 blank = " " ;
62 }
63 printf( "\n" ) ;
64 }
65 }
66 }
67
68 return 0 ;
69 }