1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #include<bits/stdc++.h> using namespace std; struct president { string price; int n; }a[100]; int m; bool cmp(president x,president y); int main() { cin>>m; for(int i=1;i<=m;i++) { cin>>a[i].price; a[i].n=i; } sort(a+1,a+m+1,cmp); cout<<a[1].n<<endl<<a[1].price; } bool cmp(president x,president y) { if(x.price.length()!=y.price.length()) return x.price.length()>y.price.length(); else return x.price>y.price;
}
|