题目链接

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

这题把%s与gets()的输入法搞混了一直感觉没有错,就是找不出哪里错了,

题目思路不是很难。

直接看代码

#include<stdio.h>
#include<string.h>
int main(void)
{
char s[10];
int l,i,j,flag;
int t,n;
scanf("%d",&t);
while(t--)
{
flag=0;
j=0;
scanf("%d",&n);
getchar();
while(n--)
{
gets(s);
l=strlen(s);
if(l==1)
{
if(flag)
printf("%c",s[0]-32);
else
printf("%c",s[0]);
}
else if(l==4)
{
flag=!flag;
}
else
{
if(flag)
printf("%c",s[6]);
else
printf("%c",s[6]-32);
}
}
printf("\n");
}
return 0;
}

如果熟悉sscanf()的也可以这样做

#include<stdio.h>

#include<string.h>
int main()
{
    int t,n,i,k;
    char a[110][10];
    char b[10],c[10];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        getchar();
        for(i=0;i<n;i++)
        {
             gets(a[i]);
        }
        k=0;
        for(i=0;i<n;i++)
        {
           sscanf(a[i],"%[^ ]",b);
           sscanf(a[i],"%*s%s",c);
           if(strcmp(b,"Caps")==0)
           {
               k++;
               continue;
           }
           else if(strcmp(b,"Shift")==0)
           {
               if(k%2==0)
               printf("%c",c[0]-32);
               else
               printf("%c",c[0]);
           }
           else if(k%2==0)
           printf("%s",b);
           else if(k%2==1)
           printf("%c",b[0]-32);
        }
        printf("\n");
    }
    return 0;
}

HDU-2573-Typing的更多相关文章

  1. HDU 2577

    How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  2. HDU 2577---How to Type

    HDU  2577 Description Pirates have finished developing the typing software. He called Cathy to test ...

  3. HDU 2577 分情况多维DP

    How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  4. HDU 1298 T9【字典树增加||查询】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1298 T9 Time Limit: 2000/1000 MS (Java/Others)    Memo ...

  5. hdu 2578 Dating with girls(1) (hash)

    Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  6. HDU 2578 Dating with girls(1) [补7-26]

    Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  7. HDU 2577 How to Type (线性dp)

    How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  8. Python标准库--typing

    作者:zhbzz2007 出处:http://www.cnblogs.com/zhbzz2007 欢迎转载,也请保留这段声明.谢谢! 1 模块简介 Python 3.5 增加了一个有意思的库--typ ...

  9. 最牛的打字效果JS插件 typing.js

    最新在做公司的一个项目,需要实现一个敲打代码的动画效果,粗意味比较简单,果断自己直接开写,写着写着发现是一个坑.需要支持语法高亮,并不能直接简单的用setTimeout来动态附件innerHTML.苦 ...

  10. Monkey Patch/Monkey Testing/Duck Typing/Duck Test

    Monkey Patch Monkey Testing Duck Typing Duck Test

随机推荐

  1. eclipse中创建NDK和JNI开发环境最简单配置方法

    一.使用环境 1.windows64位操作系统 2.ADT为adt-bundle-windows-x86_64-20130917 3.NDK为android-ndk-r9b 二.配置生成头文件.h ⒈ ...

  2. hudson配置教程

    Hudson配置教程 hudson是个优 秀的开源工具,可惜是小日本开发的.这点不爽.拿过来用吧.我们公司(Qisda)的用途是 用来晚上定时的抓Android的代码,然后编译,保存img文件,然后根 ...

  3. cc2530 T3定时器控制引脚P1_1的亮灭

    /**************************************************************************** * 文 件 名: main.c * 作 者: ...

  4. 【2013 ICCV】Abnormal Event Detection at 150 FPS in MATLAB

    2. method 把每一帧变成不同尺度,并且把每一层分成互不覆盖的patch.连续的5帧堆叠在一起形成时空立方体.对时空立方体计算3D梯度特征[11].这些视屏序列中的特征,根据空间位置的相关性,进 ...

  5. bootstrap中可用的图标集

  6. ural1028 Stars

    Stars Time limit: 0.25 secondMemory limit: 64 MB Astronomers often examine star maps where stars are ...

  7. [iOS]C语言技术视频-06-程序循环结构(for{})

    下载地址: 链接: http://pan.baidu.com/s/1dD11Zwt 密码: rke9

  8. unity3d热更新解决方案,使用ulua插件开发的框架。

    ulua插件下载地址 www.ulua.org,下面要说的是ulua的开发框架. 首先是 LuaLoader 类,它负责把一个 lua 的 table 加载起来,使此 lua 的 table 像一个 ...

  9. memcached 第二篇----安装使用

    摘要:set add replace get delete gets cas stats 和 flush_all 命令 获取所有key  .你可以使用MemCachedClient的statsItem ...

  10. ucgui汉字库存放到外部的flash(控件可用)及写外部FLASH小软件

    源:ucgui汉字库存放到外部的flash(控件可用)及写外部FLASH小软件 如何将ucgui的汉字库存放到外部的flash memory(ucgui)(汉字库)(外部flash) ucgui的字库