http://acm.hdu.edu.cn/showproblem.php?pid=1266
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int n,i,j; 6 char s[10000]; 7 scanf("%d",&n); 8 gets(s); 9 while(n--) 10 { 11 gets(s); 12 i=strlen(s)-1; 13 while(s[i]=='0') 14 i--; 15 j=i+1; 16 if(s[0]<'0'||s[0]>'9') 17 printf("%c",s[0]); 18 while(s[i]>='0'&&s[i]<='9'&&i>=0) 19 printf("%c",s[i--]); 20 for(;s[j]!='\0';j++) 21 printf("%c",s[j]); 22 printf("\n"); 23 } 24 return 0; 25 }