Word Reversal (简单字符串处理)
题目描述:
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.
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之前要吃掉换行
Word Reversal (简单字符串处理)的更多相关文章
- zoj1151 zoj1295 Word Reversal 字符串的简单处理
Word Reversal Time Limit: 2 Seconds Memory Limit:65536 KB For each list of words, output a line ...
- CF 208A Dubstep(简单字符串处理)
题目链接: 传送门 Dubstep Time Limit: 1000MS Memory Limit: 32768 KB Description Vasya works as a DJ in t ...
- C# 利用占位符替换word中的字符串和添加图片
利用占位符替换word中的字符串和添加图片 ///<summary> /// 替换word模板文件内容,包括表格中内容 /// 调用如下:WordStr ...
- 第一部分之简单字符串SDS(第二章)
一,什么是SDS? 1.引出SDSC字符串:c语言中,用空字符结尾的字符数组表示字符串简单动态字符串(SDS):Redis中,用SDS来表示字符串.在Redis中,包含字符串值的键值对在底层都是由SD ...
- hdu 5059 简单字符串处理
http://acm.hdu.edu.cn/showproblem.php?pid=5059 确定输入的数是否在(a,b)内 简单字符串处理 #include <cstdio> #incl ...
- aspose.word 使用简单方法
aspose.word使用简单方法 概念介绍 使用aspose生成word报表步骤: 加载word模板 提供数据源 填充 加载模板 提供了4种重载方法 1 2 3 4 5 public Documen ...
- C 封装一个通用链表 和 一个简单字符串开发库
引言 这里需要分享的是一个 简单字符串库和 链表的基库,代码也许用到特定技巧.有时候回想一下, 如果我读书的时候有人告诉我这些关于C开发的积淀, 那么会走的多直啊.刚参加工作的时候做桌面开发, 服务是 ...
- 1442: Neo 的简单字符串(字符串)
1442: Neo 的简单字符串 时间限制: 10 Sec 内存限制: 128 MB 提交: 9 解决: 3 统计 题目描述 Neo 给你一系列字符串,请你输出字符串中的不同单词个数以及总单词个数. ...
- java使用poi读取word(简单,简约,直观)
java使用poi读取word(简单,简约,直观) 说明 其实poi的官网上面都是有接口和样例的,只是都是英文 例如网址:http://poi.apache.org/spreadsheet/quick ...
随机推荐
- linux查看RAID信息
linux查看RAID信息 发表于2013 年 12 月 22 日 RAID分为软RAID和硬RAID 软RAID查看 cat /proc/mdstat 硬RAID查看 在启动画面进raid卡查看 I ...
- java 注释annotation学习---两篇不错的blog
深入理解Java:注解(Annotation)自定义注解入门 ---- http://www.cnblogs.com/peida/archive/2013/04/24/3036689.html 深入理 ...
- ASP.Net Core 2.2 MVC入门到基本使用系列 (二)
本教程会对基本的.Net Core 进行一个大概的且不会太深入的讲解, 在您看完本系列之后, 能基本甚至熟练的使用.Net Core进行Web开发, 感受到.Net Core的魅力. 本教程知识点大体 ...
- C# 动态创建数据库三(MySQL)
前面有说明使用EF动态新建数据库与表,数据库使用的是SQL SERVER2008的,在使用MYSQL的时候还是有所不同 一.添加 EntityFramework.dll ,System.Data.En ...
- 获取当前人IP地址
/*** 获取访问的IP地址* @date 2018年11月26日上午11:31:49* @user : taoshao* @param request* @return*/public String ...
- Python3.5 学习十九 Django分模块讲解 MTV+URL
本节内容概述: 表单提交的Method使用规则:get 获取数据 post提交数据 单选使用get 多选使用getlist request.POST.getlist("favor" ...
- linux安装mysql详细步骤
最近买了个腾讯云服务器,搭建环境. 该笔记用于系统上未装过mysql的干净系统第一次安装mysql.自己指定安装目录,指定数据文件目录. linux系统版本: CentOS 7.3 64位 安装源文件 ...
- Linux例行工作与系统管理(13)
Linux 系统的任务是由cron(crond)这个系统服务来控制的,Linux系统上面原本就有非常多的计划性工作,因此这个系统服务是默认启动的.另外,由于使用者自己也可以设置计划任务,所以Linux ...
- Linux学习笔记-基本操作3
1. vim编辑器的使用2. gcc编译器3. 静态库的制作 -- lib4. 动态库的制作 -- dll vi -- vimvim是从vi发展过来的一款文本编辑器vi a.txt前提: 安装了 ...
- Spring中ioc的实现原理
学习过Spring框架的人一定都会听过Spring的IoC(控制反转) .DI(依赖注入)这两个概念,对于初学Spring的人来说,总觉得IoC .DI这两个概念是模糊不清的,是很难理解的,今天和大家 ...