码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • C - Check The Text(string)


    C - Check The Texticon-default.png?t=M5H6https://vjudge.csgrandeur.cn/problem/Gym-102263C

    Roze has a special keyboard which consists only of 29 keys:

    -26 alphabetic a-z keys, which prints the 26 lowercase Latin letters.

    -"Space" key, which prints a single space.

    -"CapsLock" key, which converts the status of the letters keys from lowercase to uppercase and vice versa. The status initially is lowercase.

    -"Backspace" key, which deletes the last letter/space that was written on the screen.

    If Roze presses "Backspace" and there is nothing to delete on the screen, nothing will happen.

    Given the text that Roze had to print and the order of the keys she has pressed on the keyboard, check if Roze has printed the text correctly (including exactly one space between every two words).

    Input

    The first line contains an integer nn (1<n<2000), which is the number of the words in the text Roze has to print.

    Then n strings represent the text Roze has to print separated by exactly one space.

    Each string consists only of uppercase and lowercase Latin letters, and the total length of all strings less than 2000

    The following line contains an integer mm (1<m<2000), which is the number of the keys Roze has pressed.

    Then m lines, each line contains a string that represents the key was pressed.

    It's guaranteed that the last key pressed is a letter and the first key is not a space key.

    Output

    Print a single line containing the result of checking.

    If Roze has printed the text correctly, print "Correct". Otherwise, print "Incorrect".

    Example

    input

    Copy

    2
    Hello World
    18
    CapsLock
    h
    CapsLock
    e
    l
    l
    Backspace
    o
    Space
    w
    o
    Backspace
    Backspace
    w
    o
    r
    l
    d
    

    output

    Copy

    Incorrect

     

    1. #include<bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. int n,m,flag=1,ans=1;
    6. string a;
    7. string s;
    8. string v;
    9. scanf("%d",&n);
    10. getchar();//别忘了!!!
    11. getline(cin,a);
    12. scanf("%d",&m);
    13. getchar();//别忘了!!!
    14. while(m--)
    15. {
    16. getline(cin,s);
    17. if(s=="CapsLock")
    18. {
    19. flag++;
    20. }
    21. else if(s=="Space")
    22. {
    23. v+=" ";
    24. }
    25. else if(s=="Backspace")
    26. {
    27. if(v.size())//注意别忘了,否则一直erase会越界
    28. v.erase(v.size()-1,1);
    29. }
    30. else
    31. {
    32. if(flag%2==0)
    33. {
    34. v+=(s[0]-32);//注意不是s
    35. }
    36. else
    37. {
    38. v+=s[0];
    39. }
    40. }
    41. }
    42. if(a==v)
    43. printf("Correct");
    44. else
    45. printf("Incorrect");
    46. return 0;
    47. }

  • 相关阅读:
    多线程编程模式-Producer-consumer
    Error: svn: E155004: Run ‘svn cleanup‘ to remove locks
    【优化调度】基于NSGAII算法的车辆充电调度策略研究含Matlab代码
    Python中series.unique()返回序列中所有不重复的元素。
    Flutter实现地图上汇聚到一点的效果。
    应用软件运维服务方案(word原件)
    『 CSS实战』CSS3 实现一些好玩的效果(2)
    重生奇迹MU召唤术师攻略(重生奇迹MU召唤技能)
    JS响应替换|解决谷歌验证码混淆js还原替换后的跨域问题
    前任开发在代码里下毒了,支付下单居然没加幂等
  • 原文地址:https://blog.csdn.net/QZZ_PP/article/details/125627242
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号