10: Word sorting, 10 word sorting
10: Word sorting
- View
- Submit
- Statistics
- Question
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
Enter a word sequence. adjacent words are separated by one or more spaces. Please output these words in Lexicographic Order. Duplicate words must be output only once. (Case Sensitive)
-
Input
-
A word sequence consists of at least one word and a maximum of 100 words. Each word cannot exceed 50 characters in length. Each word is separated by at least one space. Data does not contain letters or spaces.
-
Output
-
These words are output in Lexicographic Order, and repeated words are output only once.
-
Sample Input
-
She wants to go to Peking University to study Chinese
-
Sample output
-
ChinesePekingSheUniversitygostudytowants
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 string a[1001]; 5 int main() 6 { 7 int i=0; 8 while(cin>>a[i]) 9 {10 i++;11 }12 sort(a+0,a+i+1);13 for(int j=1;j<i+1;j++)14 {15 if(a[j]==a[j+1])16 continue;17 cout<<a[j]<<endl;18 }19 return 0;20 }