一开始想到了使用MAP,但是c++不知道怎么遍历MAP
#include <iostream>
#include <map>
using namespace std;
int main(){
int n;
while(cin >> n){
getchar();
map<int,string> str;
for(int i = 0;i < n;i ++){
string s;
getline(cin,s);
if(s == "stop"){
break;
}
int size = s.size();
str[size] = s;
}
map<int,string>::iterator it;
for(it = str.begin();it != str.end();it ++){
cout << it->second << endl;
}
}
return 0;
}