题目链接

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. JQuery的隐式迭代和each函数和map函数

    1.JQuery选择器选择出来的是一个数组对象,可是给这些每一个元素都要设置内容时,就会隐式迭代,JQuery自己实现内部循环给每个元素绑定上设置. 2.如果是获取的话,那就是默认获取第一个元素的值. ...

  2. ASP.NET Security

    <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout ...

  3. [Java]局域网五子棋

    提示: 下面给的代码有问题哦,可以自己去调试 可用版下载 请点击这里 密码:x6ve(退出程序,端口并没有被关闭,可自行修改代码实现) img

  4. soot的安安装与使用

    soot 工具是一个可以分析多种源代码的工具,可以进行插桩,最新版本可对android apk文件,进行相应的分析以往可以直接在eclipse里面在线安装. soot(A framework for  ...

  5. location下的属性集锦

    location.protocol="http:"//即,协议 location.hostname="zhidao.baidu.com"//即,主机域名

  6. input有许多,点击按钮使用form传递文本框的值

    input有许多,点击按钮使用form传递文本框的值 <form name="form1" method="post" action="< ...

  7. 必须熟悉的vim快捷键操作

    转载请表明出处http://www.dabu.info/?p=801 Vim/Vi 没有菜单,只有命令 Vim/Vi 工作模式介绍:插入模式 和  命令模式 是vi的两个基本模式.——插入模式 ,是用 ...

  8. 基于STM32的uCOS-II移植详解

    百度:基于STM32的uCOS-II移植详解 源:基于STM32的uCOS-II移植详解

  9. IOS开发-UI学习-UITabBarController的使用

    UITabBarController具体实例如下图 我们最常见的就是微信最下面的四个按钮,通过这四个按钮可以导航到不同的界面. UITabBarController是一个容器,以下的例程中给UITab ...

  10. Android实现渐显按钮的左右滑动效果

    本示例演示在Android中实现带渐显按钮的左右滑动效果. 关于滑动效果,在我的上一篇博文中提到过,有兴趣的朋友可以访问: http://www.cnblogs.com/hanyonglu/archi ...