Created
January 3, 2017 10:46
-
-
Save splitline/b10175c276353fafdc0b8a12e11733a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
char in[10000]; | |
while(gets(in)){ | |
int len=strlen(in),w_num=0; | |
char symbol=in[len-1],words[1000][100],tmp[100]; | |
in[--len]='\0'; | |
for(int i=0,j=0,p=0;i<=len;i++){ | |
if(in[i]==' '||in[i]=='\0'){ | |
strcpy(words[j++],tmp); | |
w_num=j; | |
p=0; | |
memset(tmp,0,sizeof(tmp)); | |
} | |
else | |
tmp[p++]=in[i]; | |
} | |
for(int i=w_num-1;i>=0;i--) | |
printf("%s%c",words[i],i==0?symbol:' '); | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment