#include "stdio.h" #include "string.h" int main(){ char words[500001]; int start,end,i; int flag=-1; gets(words); end=strlen(words)-1; while(end>=0){ //如果end遇到字母,则让start向前遍历找到单词的开头 if(words[end]==' '){ end--; }else{ if(flag==1){ printf(" "); } start=end-1; while(start>=0&&words[start]!=' '){ start--; } for(i=start+1;i<=end;i++){ printf("%c",words[i]); } end=start; flag=1; } } return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)