HDU 1062 Text Reverse(水~)
2015-08-29 10:46
197 查看
Description
给出一些字符串,将这些字符串中所有的单词反序后输出转化后的字符串
Input
第一行为用例组数T,每组用例占一行为一字符串
Output
对于每组用例,输出转化后的字符串
Sample Input
3
olleh !dlrow
m’I morf .udh
I ekil .mca
Sample Output
hello world!
I’m from hdu.
I like acm.
Solution
简单字符串处理,注意ungetc函数的使用,这个函数是将读入的一个或多个字符退回到输入流中
Code
给出一些字符串,将这些字符串中所有的单词反序后输出转化后的字符串
Input
第一行为用例组数T,每组用例占一行为一字符串
Output
对于每组用例,输出转化后的字符串
Sample Input
3
olleh !dlrow
m’I morf .udh
I ekil .mca
Sample Output
hello world!
I’m from hdu.
I like acm.
Solution
简单字符串处理,注意ungetc函数的使用,这个函数是将读入的一个或多个字符退回到输入流中
Code
#include<stdio.h> #include<string.h> char word[1005]; int main() { int n; scanf("%d",&n); while(scanf("%s",word)!=EOF) { for(int i=strlen(word)-1;i>=0;i--) putchar(word[i]); char c; while(c=getchar(),c ==' '||c=='\t'||c=='\n')//空格/跳格/换行字符直接输出 putchar(c); ungetc(c,stdin);//将读入的字符退回 } return 0; }
相关文章推荐
- SDUT 3305 质数中的质数
- Java中基于Rxtx的串口操作
- Android的XML解析
- 面向对象
- 大小端字节序
- xss小试
- logback 配置
- jquery制作拉开帷幕特效
- 获取系统环境变量: ACE_OS::getenv
- SDUT 3304 选课大作战
- 关于UNICODE VC项目二三事
- Spring-事件体系
- 【权值初始化+有条件的MST】hdu 1875 畅通工程再续
- OEL7.1安装oracle 12c简单步骤
- Dancing Links DLX
- netty5学习笔记-内存池3-PoolChunkList
- 重载引用参数(c++ primer plus -6th)
- 全国省市区数据库
- 微信公众号网页授权获取用户基本信息
- netty5学习笔记-内存池3-PoolChunkList