直接读取字符串,然后倒序输出
要注意的就是中间的空白字符必须全部输出,不然会PE。
/* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <cstdio> #include <cstring> char s[1001],t; main() { scanf("%*d"); while(~scanf("%s",s)) { for(int i=strlen(s)-1;i>=0;)putchar(s[i--]); while((t=getchar())==' '||t=='\n')putchar(t); ungetc(t,stdin); } }