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.