"尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F Final Ugly English

F.Final Ugly English
Time Limit: 1000 MSMemory Limit: 32768 K
Total Submit: 2074(405 users)Total Accepted: 294(291 users)Special Judge: No
Description

ACM twist-toy encountered such a problem in the work,

 this article, to ensure that this article 

only lowercase letters 

and spaces, please send the articles in each 

word inverted output, such as "hello world this is

 an competition". You 

should output "olleh dlrow siht si na noititepmoc".

Input

A group of data, each line of data input from the 

lower case letters and spaces of the article,

 the length of not more than

 one thousand

Output
Output a line for each word after the reversal of the article.
Sample Input
hello world this is an competition
Sample Output
olleh dlrow siht si na noititepmoc


一遇到这种题就gg了, 大哭,一定得好好补补这种题型

注意:1。多组输入。2.输出后得字符串无空格

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
string a;
/ar b[1005];
int main()
{
    while(getline(cin,a))
    {
        int len=a.size();
        //printf("%d\n",len);
        int j=0,k=0;
        for(int i=0; i<=len; i++)
        {
            //printf("%d\n",a[i]);
            if(a[i]<'a'||a[i]>'z')
            {
                //printf("%d \n",i);
                for(j=i-1; j>=k; j--)
                {
                    printf("%c",a[j]);
                }
                k=i+1;
                if(i<len)
                    printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}







转载于:https://www.cnblogs.com/zxy160/p/7215131.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值