ZOJ 3168 水不解释
View Code
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 char s1[1001],s2[1001]; 6 int cmp (const void *a,const void *b) 7 { 8 if( *(char*)a < *(char *)b ) 9 return 1; 10 return -1; 11 } 12 13 int main() 14 { 15 int i,j,k,len; 16 17 while(scanf("%s",s1)!=EOF) 18 { 19 getchar(); 20 memset(s2,'0',sizeof(s2[0])); 21 len = strlen(s1); 22 k = 0; 23 for(i=0; i<len; i++) 24 { 25 if(s1[i]=='Z'||s1[i]=='O'||s1[i]=='J'||s1[i]=='7') 26 { 27 s2[k++] = s1[i]; 28 } 29 } 30 qsort(s2,k,sizeof(s2[0]),cmp); 31 for(i=0; i<len; i++) 32 { 33 if(s1[i]!='O' &&s1[i]!='Z'&&s1[i]!='J'&&s1[i]!='7') 34 s2[k++] = s1[i]; 35 } 36 s2[k]='\0'; 37 printf("%s\n",s2); 38 } 39 return 0; 40 } 41