山东省第七届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!

输入

 Multiple test cases. The first line contains a positive integer T (T <= 1000), indicating the number of test cases.

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<iostream>  
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;  
}  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值