码迷,mamicode.com
首页 > 编程语言 > 详细

按地名字符,给地名排序。

时间:2014-11-27 14:35:00      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:c++   namespace   技术   经验   计算机科学   

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,m;
    string a,country[10];
    for(n=0; n<10; ++n)
    {
        cin>>country[n];
    }
    for(m=0; m<9; ++m)
    {
        for(n=0; n<5; ++n)
        {
            if(country[n]>country[n+1])
            {
                a=country[n];
                country[n]=country[n+1];
                country[n+1]=a;
            }
        }
    }
    for(n=0; n<10; ++n)
    {
        cout<<country[n]<<endl;
    }
   return 0;
}

bubuko.com,布布扣

按地名字符,给地名排序。

标签:c++   namespace   技术   经验   计算机科学   

原文地址:http://blog.csdn.net/i__am__legend/article/details/41544835

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!