#include "stdio.h" #include "string.h" void main() { int i,k,j; char t; int count=0; char s[100]; //gets(s); // printf("%d",strlen(s)); for(;gets(s)!=NULL;) { for(i=-1;s[i]!='\0';i++) { if(s[i+1]!=' '&&s[i+1]!='\0') count++; if(s[i+1]==' '||s[i+1]=='\0') { k=i; for(j=k;j>k-count;j--,k++) { t=s[j];s[j]=s[k-count+1];s[k-count+1]=t; } count=0; } } for(i=0;s[i]!='\0';i++) { if(s[i+1]=='\0') printf("\n"); else printf("%c",s[i]); } } } |
Double click to view unformatted code.