CUIT 2016 新生训练题第一周 D-Text Reverse
来源:互联网 发布:linux时钟同步设置 编辑:程序博客网 时间:2024/05/18 01:46
Text Reverse
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 25 Accepted Submission(s) : 13
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
3olleh !dlrowm'I morf .udhI ekil .mca
Sample Output
hello world!
I'm from hdu.
Ilike 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.
[/hint]
#include<string.h>#include<stdio.h>int main(){ int i,N,len,j,k,t; char a1[1000],a2[100]; scanf("%d",&N); getchar(); while(N--) { gets(a1); len=strlen(a1); for(i=0,j=0,t=0;i<len;i++) { if(a1[i]!=' ' ) a2[j++]=a1[i]; else { if(t>0) printf(" "); for(k=j-1;k>=0;k--) printf("%c",a2[k]); j=0; t++; } if(i==len-1) { printf(" "); for(k=j-1;k>=0;k--) printf("%c",a2[k]); } } printf("\n"); } return 0;}
0 0
- CUIT 2016 新生训练题第一周 D-Text Reverse
- CUIT 2016 新生训练题第一周 A - 大菲波数
- CUIT 2016 新生训练题第一周 C - Bull Math
- CUIT 2016 新生训练题第一周 E - N!
- CUIT 2016 新生训练题第一周 B - Adding Reversed Numbers
- 第一周训练 E题
- 2017CUIT & FJUT & SWPU三校联合新生赛-决赛 D,E
- 暑假第一周D,E,F题
- 中国(北方)大学生程序设计训练赛(第一周)(Problem D: 数学题-二分+双指针)
- 中国(北方)大学生程序设计训练赛(第一周)-D (二分)
- 2015-2016 下半学期 第一周 训练
- GDUT 2016新生赛D题 有趣的游戏
- java编程技能训练(第一周)
- 第一周-入门训练-序列求和
- 新高一第一周训练小计
- 北方大学训练赛,第一周
- 机器学习训练营---第一周总结
- 暑假第一周 D CodeForces 660 B.
- SQL GROUP BY 语句
- iOS - 页面之间传值的实现 - 代理
- [问题记录]hdfs删除文件提示rmr: Failed to move to trash
- Android 关于文件存储路径的总结
- 自适应辛普森法
- CUIT 2016 新生训练题第一周 D-Text Reverse
- H5知识 -- 表单篇
- 在windows10上使用docker哪些坑
- 邮件营销之模板设计 | 五分钟搞定,秒变编辑达人!
- MySql连接字符串
- 好压(HaoZip)的命令行模式用法介绍-转载
- NAT与NAT穿透(二)
- SQL 快速参考
- Linux多线程程序设计