标签:style blog io color ar os for sp div
1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<iostream> 5 #include<algorithm> 6 #include<queue> 7 #include<cmath> 8 using namespace std; 9 struct strx 10 { 11 char c[20]; 12 int x; 13 } str[10010]; 14 int cmp(const void*a,const void*b) 15 { 16 return strcmp((*(strx*)a).c,(*(strx*)b).c); 17 } 18 19 int main() 20 { 21 int n=-1; 22 while(cin>>str[++n].c); 23 qsort(str,n,sizeof(str[0]),cmp); 24 for(int i=0;i<n;i++) 25 cout<<str[i].c<<endl; 26 return 0; 27 }
/*这是将char数组放入结构体将其排序;
标签:style blog io color ar os for sp div
原文地址:http://www.cnblogs.com/coutendl/p/4075851.html