新方法:结构体排序。
我们可以把输入的城市名称和温度存到结构体数组 里。
然后根据结构体中的 排序,最后输出 最小的 即可。
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node{
string s;
int t;
}f[100010];
bool cmp(const node &a,const node &b){
return a.t<b.t;
}
signed main(){
ios::sync_with_stdio(false);
int k = 1;
while(1){
cin>>f[k].s>>f[k].t;
if(f[k].s == "Waterloo"){
break;
}
k++;
}
sort(f+1,f+k+1,cmp);
cout<<f[1].s;
return 0;
}