对输入字符串的字符的倒置,在这个程序中,我觉得自己最大的问题是怎么识别一个字符,代码中有t个字符串,每个字符串,每个字符串中有若干个单词,单词之间有空格,所以对于下列的正确答案,我的疑惑是当我键盘输入时,电脑怎么识别带有空格的一行字符

这道题的三个重点:1、系统对于键盘输入的字符串的识别,在下面的正确代码中,当执行while循环,输入字符串,字符串就被存入数组中,那他是怎么识别空格的呢

2、对于每一个单词的字符倒置 3、在输出每一个字符串(单词)的时候时手动输出空格

#include<stdio.h>

int main()

{

int t,f,i,j,k;
char s[1005];
scanf("%d",&t);

while(t--)
{
gets(s);
f=strlen(s);
for(i=0;i<=f;i++)
{
if(s[i]==' '||i==f)
{

for(j=i-1;j!=k&&j>=0;j--)在该代码之前并没有对k进行赋值
putchar(s[j]);
k=i;
if(i!=f)/////////   f是字符串的长度,在前面的if条件中if(s[i]==' '||i==f) 那这句话是在s[i]==' '时才输出空格,那说明在前面的if中就已经识别了空格,不知我这样理解对不对
putchar(' ');
}
}
printf("\n");
}
return 0;
}

Problem - 1062 http://acm.hdu.edu.cn/showproblem.php?pid=1062的更多相关文章

  1. HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632

    http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...

  2. HDU 4911 http://acm.hdu.edu.cn/showproblem.php?pid=4911(线段树求逆序对)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911 解题报告: 给出一个长度为n的序列,然后给出一个k,要你求最多做k次相邻的数字交换后,逆序数最少 ...

  3. KMP(http://acm.hdu.edu.cn/showproblem.php?pid=1711)

    http://acm.hdu.edu.cn/showproblem.php?pid=1711 #include<stdio.h> #include<math.h> #inclu ...

  4. 待补 http://acm.hdu.edu.cn/showproblem.php?pid=6602

    http://acm.hdu.edu.cn/showproblem.php?pid=6602 终于能够看懂的题解: https://blog.csdn.net/qq_40871466/article/ ...

  5. HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257

    Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...

  6. http://acm.hdu.edu.cn/showproblem.php?pid=2579

    #include<stdio.h> #include<string.h> #include<queue> #define N 110 int m, n, k, x1 ...

  7. KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594

    riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...

  8. HDU 2544 最短路 http://acm.hdu.edu.cn/showproblem.php?pid=2544

    //代码: //方法1:Dijkstra's Algorithm #include<stdio.h> #include<math.h> #include<string.h ...

  9. HDU1973 http://acm.hdu.edu.cn/showproblem.php?pid=1973

    #include<stdio.h> #include<stdlib.h> #include<string.h> #include<queue> #inc ...

随机推荐

  1. django2.0.6 连接使用redis集群

    环境需要: django >= 1.8.x python 2.7 或者python >= 3.4 安装django-cluster-redis包: pip install django-r ...

  2. 安装mysql5.6

    1.创建一个不能登录的的用户: 2.下载一个数据库包: wget 下载网址 3.安装相关依赖包: yum -y install make gcc-c++ cmake bison-devel ncurs ...

  3. 细数Linux的文件权限

    普通权限 普通权限使用ls -l查看,最前面显示的即是,如: # ls -l .txt -rw-r--r-- 1 root root 8338 7月 19 20:27 1.txt 权限介绍: -/d/ ...

  4. D9 图论综合题

    1.白银莲花池 LUOGU 2411 第一种思路:当然我们可以写三个bfs a掉这个题,这写下来一二百行要有了吧: 第二种:我们可以在一个bfs中维护所有的信息,一个方向数组,从起点开始,向八个方向扩 ...

  5. 论文笔记:AdaScale: Towards real-time video object detection using adaptive scalingAdaScale

    AdaScale: Towards real-time video object detection using adaptive scaling 2019-02-18 16:14:17 Paper: ...

  6. css3常用动效以及总结

    (迁移自旧博客2017 08 06) CSS3 文本效果: box-shadow:盒子阴影,可以给卡片添加提高美化效果.可广泛应用于内容展示页面. <div class="card&q ...

  7. jsp 遍历集合——关于获取集合的长度

    一,关于获取集合长度问题 在jsp页面中不能通过${list.size}取列表长度,而是 EL表达式不能获取集合的长度 如:${list.size} <%@ taglib uri="h ...

  8. 记一次IIS发布网站导致系统时常跳入登录页面的问题解决

    服务器:winserver2012R2 iis 发布网站后,正常浏览网页,时常跳到登录页面,第一反应session过期,因为登录信息都存在session,但session 都是默认配置过期时间为20分 ...

  9. Linux之DHCP搭建命令集锦

    systemctl start dhcpd        //启动DHCP systemctl enable dhcpd                //配置服务开机启动 ps aux | grep ...

  10. julia 安装

    https://julialang.org/downloads/ 下载安装程序,拖拽完成安装