Title Description
Given n strings, the arrangement of n strings in lexicographic order.
Enter a description:
A first input acts a positive integer n (1≤n≤1000), n n behavior following string (string length ≤100), the string contains only lowercase letters.
Output Description:
N data output lines, the output is arranged in a lexicographic order strings.
Example 1
Export
copyboat boot cap card cat to too two up
idea: compare the violence of it, save it directly, and then use the comparison string, and finally bubbling wave output
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
using namespace std;
int main()
{
int n;
string str[1000];
string index;
cin>>n;
for(int i = 0; i < n; i++) {
cin>>str[i];
}
for(int i = 0; i < n; i++) {
for(int j = i + 1 ; j < n; j++) {
if(str[i]>str[j]){
index = str[i];
str[i] = str[j];
str[j] = index;
}
}
}
for(int i = 0; i < n; i++)
{
cout << str[i] << endl;
}
return 0;
}