山东省第七届ACM省赛------Reversed Words

网友投稿 303 2022-11-29

山东省第七届ACM省赛------Reversed Words

Reversed Words

Time Limit: 2000MS Memory limit: 131072K

题目描述

Some aliens are learning English. They have a very strange way in writing that they revered every word in the sentence but keep all the words in common order. For example when they want to write “one two three”, they will write down “eno owt eerht”.

Now we’ve got some sentence written by these aliens, translate them! And maybe we will know some of their secrets!

输入

For each test cases, there will be one line contains only lower case letters and spaces. The length of each line will be no more than 10000. Test cases which are longer than 5000 will be less than 50. Continuous letters are seen as a word, words are separated by spaces. There won’t be two adjacent spaces in the input. Space won’t be the first or the last character.

输出

One line per case, the translated sentence.

示例输入

2

eno owt eerhtabcde

示例输出

one two threeedcba

来源

“浪潮杯”山东省第七届ACM大学生程序设计竞赛

题意

不需要看题目,直接看样例便可以知道题目的意思啦~

一个必须1A的题目

AC代码:

#include"stdio.h" #include"string.h" #include using namespace std; char c[10005]; int main() { int n; cin>>n; getchar(); while(n--) { gets(c); for(int i=0;i<(int)strlen(c);i++) { if(c[i]==' ') { for(int j=i-1;j>=0&&c[j]!=' ';j--) putchar(c[j]); putchar(' '); } } for(int i=strlen(c)-1;i>=0&&c[i]!=' ';i--) putchar(c[i]); printf("\n"); } return 0; }

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:YTU 3027: 哈夫曼编码
下一篇:java中的抽象类和接口定义与用法详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~