#36233: 使用


chengyanyang0510@gmail.com (YCY)

學校 : 臺北市立建國高級中學
編號 : 236518
來源 : [61.70.193.101]
最後登入時間 :
2024-04-22 20:00:39
a130. 12015 - Google is Feeling Lucky -- UVa12015 | From: [61.70.193.208] | 發表日期 : 2023-07-11 17:12

#include <iostream>
using namespace std;

struct website //建立website結構,包含網址和分數
{
string url;
int score;
};

int main()
{
int n;
cin >> n;//輸入測資數
for (int i = 0; i < n; i++)
{
website ws[10];//共10個網站
for (int j = 0; j < 10; j++)
{
cin >> ws[j].url >> ws[j].score;//輸入網址和分數
}
int max = ws[0].score;//假設第一項為最大值
for (int j = 1; j < 10; j++)
{
if (ws[j].score > max)//大於暫時最大值,則取代它
max = ws[j].score;
}
cout << "Case #" << i + 1 << ":\n";//輸出測資編號
for (int j = 0; j < 10; j++)
{
if (ws[j].score == max)//等於最大值,則輸出網址
cout << ws[j].url << endl;
}
}
return 0;
}
 
ZeroJudge Forum