Problem : (1.2.1) Text Reverse
2024-10-18 20:01:08
#include<iostream>
using namespace std;
void main()
{
char arr[1000];
int a,n;
int s,t;
cin>>a;
getchar();
for(int i=0;i<a;i++)
{
gets(arr);
n=strlen(arr);
s=0;
for(int j=0;j<=n;j++)
{
if(arr[j]==' '||arr[j]=='\0')
{
t=j;
for(int l=t-1;l>=s;l--)
{
cout<<arr[l];
}
s=t+1;
if(s!=n+1)
cout<<" ";
} }
cout<<endl;
}
}
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 |
Sample Output
hello world! |
最新文章
- java关于压缩包的处理,我这里贴出三中格式的(zip,rar,tar)解压方法(目前只用到解压,所以压缩过多研究)。
- 在 Visual Studio Code 中使用 PoweShell - CodeShell
- html5 <;input>; placeholder 属性
- python &; pandas链接mysql数据库
- pip常用命令
- Qt Chart 5.7.0 傻瓜安装教程
- 1秒破解 js packer 加密
- enode框架
- hibernate---一对一单向外键关联--XML
- vue-cli3.0 flexible&;px2rem 解决第三方ui组件库样式问题
- href=&#39;#&#39; 和 href=&#39;###&#39;
- Mybatis学习4——核心文件sqlMapperConfig.xml属性
- 优雅的vue.js
- android中的目录结构介绍
- 小白学习之Code First(三)
- SOJ 4580 动态规划之01背包 (01背包)
- Ionic Js十七:侧栏菜单
- 如何把he_llo wo_rld 变成 HeLlo WoRld
- 第166天:canvas绘制饼状图动画
- Solr调优参考