1062 字符串处理 水题
2016-06-23 21:16
330 查看
Hot~~欢迎“信息学(OI)选手”——报考杭州电子科技大学! Text Reverse Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25889 Accepted Submission(s): 10041 Problem Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them. Input The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single line with several words. There will be at most 1000 characters in a line. Output For each test case, you should output the text which is processed. Sample Input 3 olleh !dlrow m'I morf .udh I ekil .mca Sample Output hello world! I'm from hdu. I like acm. Hint Remember to use getchar() to read '\n' after the interger T, then you may use gets() to read a line and process it. Author Ignatius.L Recommend
#include<stdio.h> #include<string.h> char c[1001]; void print(int n) { for(int i=1;i<=n;i++) { gets(c);//puts(c); int len=strlen(c); for(int i=0;i<len;i++) { if(c[i]==' ') { for(int j=i-1;c[j]!=' '&&j>=0;j--) putchar(c[j]); putchar(' '); } if(i==len-1) for(int j=i;c[j]!=' '&&j>=0;j--) putchar(c[j]); } putchar('\n'); } } int main(void) { //freopen("E:\\test.txt","r",stdin); int n; while(~scanf("%d",&n)) { getchar(); print(n); } return 0; }
相关文章推荐
- 01背包
- 2021 贪心算法 (最优转载问题)水题
- 学习笔记2__布局:固定顶栏布局
- hdu 2136 素数打表
- matlab对excel数据进行排序求和
- windows7 64位 编译 openssl
- 最长公共子序列(未完成)
- 毕向东Java视频学习笔记【Day09 继承+接口+抽象类】
- 转: 通过不到100行Go代码打造你自己的容器
- Android 手势滑动
- hdu 1286 素数打表
- Android 解析后台返回为Json数据的简单例子
- MyBatis分页插件:比PageHelper都要简单,使用很灵活,目前支持Oracle和MySQL
- 结构体和预定义
- 剑指offer——序列化二叉树
- 学习shell scripts
- Anti-Goldbach's Conjecture 素数打表
- Ubuntu16.04 Server 64bit 使用LVM
- hdu3792 打表
- 网红是怎样让视频刷单再度疯狂?