Week 14th problem B: Country sort

Source: Internet
Author: User

Problem and code:

 
/* *copyright (c) 2014, the School of Computer and Control engineering, Yantai University, 
*all rights reserved. 
* File name: Number.cpp 
*:    Tan Xinxin 
* Completion Date: November 27, 2014 
* version number: v1.0 
* 
* Problem Description: The world is in turmoil, 10 countries convened an emergency meeting to discuss countermeasures. Some countries are preoccupied with how seats for delegates are scheduled to be kept up. Now put them in the dictionary order, and hurry up and discuss the matter. Please write a procedure to order the representatives of the 10 countries.
* Program output: A good order of the country name, a country line.
* *  
#include <iostream>
#include <cstring>
using namespace std;
int main ()
{
    int i,j;
    String nationname[10];
    string string1;
    For (i=0 i<10; ++i)
        cin>>nationname[i];
    For (j=0 j<9; ++j) for
        (i=0; i<=9-j; ++i)
            if (nationname[i]>nationname[i+1))
            {
                string1= Nationname[i];
                NATIONNAME[I]=NATIONNAME[I+1];
                nationname[i+1]=string1;
            }
    For (i=0 i<10; ++i)
        cout<<nationname[i]<<endl;;
    return 0;
}


Run Result:

Summary of Knowledge points:

The sorting of elements.

Learning experience:

String nationname[10]; it was first used as an int nationname[10];

I'll pay attention to it next time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.