若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1628: Word Reversal

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,246

题目描述

For each list of words, output a line with each word reversed without changing the order of the words.

输入

The first line contains a positive integer indicating the number of cases to follow. Each case is given on a line containing a list of words separated by one space, and each word contains only uppercase and lowercase letters.

输出

For each test case, print the output on one line.

样例输入

3
I am happy today
To be or not to be
I want to win the practice contest

样例输出

I ma yppah yadot
oT eb ro ton ot eb
I tnaw ot niw eht ecitcarp tsetnoc

参考代码

#include<stdio.h>
int main() 
{
    int n,i,j,k,m,x;
    char a[100];
    scanf("%d",&n);
    getchar();
    for (i=1;i<=n;i++) 
    {
        m=0;
        gets(a);
        for (j=0;;j++) 
        {
            m++;
            if(a[j]==' '||a[j]=='')
     {  x=j;
        for(k=0;k<m-1;k++)
        {   printf("%c",a[x-1]);
        x--;
        }
        m=0;
        if(a[j]!='')
           printf("%c",a[j]);
     }
     if(a[j]=='')
        break;
     }
     printf("n");
 }
 return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Dreams孤独患者 Skip 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist