输入n个国家名,要求按字母先后顺序排列,并按照顺序输出

[复制链接]
查看11 | 回复0 | 2008-5-7 11:37:38 | 显示全部楼层 |阅读模式
C++答案:(每行输入一个国家名然后回车,输入exit结束)#include #include #include using namespace std;int main (){
setcountries;
string country;
while ( cin >> country )
{
if (country == "exit")
break;
else
countries.insert(country);
}
for (set::iterator itr = countries.begin(); itr != countries.end(); itr++)
{
cout << *itr << endl;
}
system("pause");
return 0;}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行