set排序:
1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<set> 5 #include<string> 6 using namespace std; 7 set<string >s; 8 int main() 9 { 10 string a; 11 while(getline(cin,a)) 12 { 13 for(int i=0; i<a.size(); i++) 14 { 15 string tmp; 16 if(!isalpha(a[i]))continue; 17 while(isalpha(a[i])) 18 { 19 if(a[i]>='A'&&a[i]<='Z') 20 tmp+=a[i]+32; 21 else tmp+=a[i]; 22 i++; 23 } 24 s.insert(tmp); 25 } 26 } 27 for(set<string>::iterator it=s.begin(); it!=s.end(); it++) 28 { 29 cout<<*it<<endl; 30 } 31 }