输入一行单词序列,相邻单词之间由1个或多个空格间隔,请按照字典序输出这些单词,要求重复的单词只输出一次。(区分大小写)
She wants to go to Peking University to study Chinese
Chinese Peking She University go study to wants
#include<iostream> #include<algorithm> using namespace std; string a[1001]; int main() { int i=0; while(cin>>a[i]) { i++; } sort(a+0,a+i+1); for(int j=1;j<i+1;j++) { if(a[j]==a[j+1]) continue; cout<<a[j]<<endl; } return 0; }
10:单词排序
原文:http://www.cnblogs.com/lyqlyq/p/6597009.html