2015-基础(6)
来源:互联网 发布:阿里云服务器免费体验 编辑:程序博客网 时间:2024/06/01 10:16
G - G
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.
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.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.
#include <iostream>#include <cstring>using namespace std;int main(){int t,i,j,p,flag=0;char a[100000];cin >> t;cin.get();while (t--){cin.getline(a,100000);for(i=0;a[i]!='\0';i++){if(a[i]!=' '){p=i;break;}}for (i=0;a[i]!='\0';i++){if (a[i+1]==' '){for (j=i;j>=p;j--){cout << a[j];}p=i+2;}if(a[i]==' '){cout << " ";}}for (j=strlen(a)-1;a[j]!=' ';j--){cout << a[j];}cout << endl;}return 0;}
1 0
- 2015-基础(6)
- 2015-基础(1)
- 2015-基础(2)
- 2015-基础(3)
- 2015-基础(4)
- 2015-基础(5)
- 2015-基础(7)
- css基础(6)
- Java基础(6)
- 程序设计基础(C++)主页-2015级(基础班)
- SQL语言基础(6)
- 纹理映射基础(6)
- JAVA基础学习(6)
- java复习基础(6)
- JavaSe基础(6)-- 方法
- C基础(6-10)
- ACM 几何基础(6)
- c++基础(6-8)
- 2015-基础(5)
- hadoop2.6.0版本搭建伪分布式环境
- 我的合伙人
- SVN命令使用详解
- 寮步镇刨花板哪家质量好呢
- 2015-基础(6)
- 增城特厚刨花墩厂有没有呢
- 卓普小黑C2降低分辨率提高系统性能40%教程
- ITC里面显示二进制文件无效(适配64位)
- Linux下SSH安装、更新及XShell连接
- 东莞虎门镇特厚刨花板厂有没有呢
- 石龙特厚刨花墩厂有没有呢
- 东莞厚街镇刨花板生产厂家有几家呢
- [模版] 网络流最大流、费用流