题目链接 ——〉http://acm.nefu.edu.cn/JudgeOnline/problem/137.jsp

 

#include<iostream>
#include
<stdlib.h>
using namespace std;
struct Url{
    
int no, rel ;
    
string url ;
}page[
10] ;

int cmp(const void *a, const void *b){          //rel从大到小,no从小到大
    
struct Url *= (Url *)a ;
    
struct Url *= (Url *)b ;
    
if(c->rel!=d->rel)  return d->rel - c->rel ;
    
else    return c->no - d->no ;
}
int main(){
    
int n, j=0;
    cin 
>> n ;
    
while(n--){
        j 
++ ;
        
for(int i=0; i<10; i++){
            cin 
>> page[i].url >> page[i].rel ;
            page[i].no 
= i ;
        }
        qsort(page, 
10sizeof(page[0]), cmp) ;
        cout 
<< "Case #" << j << ":" << endl ;
        
for(int i=0; i<10; i++){
            cout 
<< page[i].url << endl ;
            
if(page[i].rel!=page[i+1].rel)  break ;
        }
    }
    
return 0 ;
}

 

 

posted on 2011-08-26 16:26  追逐.  阅读(1100)  评论(0编辑  收藏  举报