UVa 12015 - Google is Feeling Lucky

来源:互联网 发布:apache有什么作用 编辑:程序博客网 时间:2024/06/04 18:44

题目:给你机组数据,每组10个网址和检索能力,输出检索能力最高的网址。

分析:简单题。直接按能力值排序即可,输出多有最大的即可。

说明:这么多水题,一刷一上午╮(╯▽╰)╭。

#include <algorithm>#include <iostream>#include <cstdlib>#include <cstdio>using namespace std;struct web{string name;int    time;}W[11];bool cmp( web a, web b ){return a.time > b.time;}int main(){int T;while ( cin >> T )for ( int t = 1 ; t <= T ; ++ t ) {cout << "Case #" << t <<":" << endl;for ( int i = 0 ; i < 10 ; ++ i )cin >> W[i].name >> W[i].time;  sort( W, W+10, cmp );for ( int i = 0 ; W[i].time == W[0].time ; ++ i )cout << W[i].name << endl;}return 0;}

0 0