题目描述:

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

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a
blank line followed by N input blocks. Each input block is in the format
indicated in the problem description. There is a blank line between
input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Input

You will be given a number of test cases. 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.

Output

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

Sample Input

1

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

Sample Output

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

 //题意描述:输入一个字符串,不改变单词的顺序,将每个单词反转输出
//解题思路: 用gets读入,去头去尾后,判断出一个单词,将其复制到另一个字符串中逆序输出,直至字符串尾即可
#include<stdio.h>
#include<ctype.h>
#include<string.h> void pri(char p[])
{
int i,l=strlen(p);
for(i=;i<l;i++)
printf("#%c",p[i]);
printf("\n");
} int main()
{
int T,r,i,j,k;
char s[],*p=NULL,s2[];
scanf("%d",&T);
while(T--)
{ scanf("%d",&r);
getchar();
while(r--)
{
gets(s);
int l=strlen(s);
s[l]='\0';
//pri(s); p=s;
while(!isalpha(*p))
{
p++;
}
//pri(p); l=strlen(p);
for(i=l-;i>=;i--)
if(isalpha(p[i]))
break;
p[i+]=' ';
p[i+]='\0';
//pri(p); l=strlen(p);
for(i=;i<l;)
{
j=;
while(isalpha(p[i]))
{
s2[j++]=p[i++];
}
s2[j]='\0'; for(k=j-;k>=;k--)
printf("%c",s2[k]); if(i==l-)
printf("\n");
else
printf(" ");
i++;
}
}
if(T != )
printf("\n");
}
return ;
}
//易错分析
//gets之前要吃掉换行

最新文章

  1. WCF学习之旅—WCF中传统的异常处理(十六)
  2. JS产生随机数的几个用法!
  3. 【转】MongoDB安全配置
  4. NUnit-Console 命令行选项详解
  5. A woman without arms
  6. (转)推荐一个在Linux/Unix上架设ASP.NET的 WEB服务器--Jexus
  7. java 执行sql脚本的3种方式 (ant,ibatis,ScriptRunner)
  8. CGRectInset CGRectoffset UIEdgeInsetsInsetRect 这三个函数的使用情况
  9. React使用笔记1-React的JSX和Style
  10. vs2013 ADO联系SQL server2012数据库
  11. 如何取消Microsoft账户登录电脑
  12. ASP.NET页面之间的几种传值方法
  13. coTurn 运行在Windows平台的方法及服务与客户端运行交互流程和原理
  14. 『TensorFlow』卷积层、池化层详解
  15. [UE4]Wrap Box流布局
  16. 启动设置mongodb
  17. 微软BI 之SSIS 系列 - 在 SSIS 中使用 Web Service 以及 XML 解析
  18. shlve 模块
  19. Java 集成开发环境的介绍及下载
  20. codeforces 559b//Equivalent Strings// Codeforces Round #313(Div. 1)

热门文章

  1. [php] php - json_encode 函数
  2. google breakpad for linux(2)
  3. 201621123018《java程序设计》第13周作业总结
  4. python中硬要写抽象类和抽象方法
  5. PANIC: Missing emulator engine program for &#39;x86&#39; CPU.
  6. win7 docker 挂载共享目录
  7. Linux上安装java JDK
  8. 移动一根火柴使等式成立js版本(递归)
  9. flask_ Mongodb 的语法-排序
  10. [POC]K8 DLLhijack Test