1084 Broken Keyboard (20分)

1084 Broken Keyboard (20分)Onabrokenkey someofthekey Sowhenyoutyp thecharacter Nowgivenastr

On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.

Now given a string that you are supposed to type, and the string that you actually type out, please list those keys which are for sure worn out.

Input Specification:

Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains no more than 80 characters which are either English letters [A-Z] (case insensitive), digital numbers [0-9], or _ (representing the space). It is guaranteed that both strings are non-empty.

Output Specification:

For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.

Sample Input:

7_This_is_a_test _hs_s_a_es 

Sample Output:

7TI

 吾思:

#include 
  
    #include 
   
     #include 
    
      using namespace std; int main() { //freopen("in.txt", "r", stdin); string s1, s2, ans; getline(cin, s1); getline(cin, s2); int len1 = s1.length(), len2 = s2.length(); int i = 0, j = 0; while (i 
     
       only(60, false); for (auto &c : ans) { c = toupper(c);//得先全部变成大写,不然小写和大写在only数组中不一样。 if (!only[c-'0']) { cout << c; only[c - '0'] = true; } } return 0; } 
      
     
    
  

 liuchuo:(除了佩服还能说啥  哈哈)

#include 
  
    #include 
   
     using namespace std; int main() { string s1, s2, ans; cin >> s1 >> s2; for (int i = 0; i < s1.length(); i++) if (s2.find(s1[i]) == string::npos && ans.find(toupper(s1[i])) == string::npos)//string::npos->C++手册:As a return value, it is usually used to indicate no matches.作为find函数的返回值,意思是木找着。 ans += toupper(s1[i]); cout << ans; return 0; } 
    
  

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/225257.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月17日 上午9:43
下一篇 2026年3月17日 上午9:44


相关推荐

  • sortablejs — 强大的拖拽库

    sortablejs — 强大的拖拽库Sortable js 是一款优秀的 js 拖拽库 支持 ie9 及以上版本 ie 浏览器和现代浏览器 也可以运行在移动触摸设备中 不依赖 jQuery 支持 Meteor AngularJS React Vue Knockout 框架和任何 CSS 库 如 Bootstrap ElementUI 你可以用来拖拽 div table 等元素 一 sortablejs 最基本的示例 divid itxst divdata id a item1 lt divdata id a divid itxst

    2026年3月17日
    2
  • salt的grains工具和pillar工具使用详解

    salt的grains工具和pillar工具使用详解什么是 grains 工具 Salt 附带一接口 用于获取有关底层系统的信息 Salt 的 grains 主要存储静态数据 用来收集 minion 端的一些数据 比如 操作系统 域名 IP 地址 内核 操作系统类型 内存或者其他系统属性 Minion 端在启动时会读取 grains 数据 如果有新的 grains 数据需要重启 minion 服务或者在 master 端使用 salt 命令进行刷新一 minion 端的 roles 之前

    2025年8月11日
    10
  • linux解压zip中文乱码问题「建议收藏」

    linux解压zip中文乱码问题「建议收藏」unzip-OCP936xxx.zip

    2022年5月10日
    36
  • 使用 Java8的 stream对list数据去重,使用filter()过滤列表,list转map「建议收藏」

    使用 Java8的 stream对list数据去重,使用filter()过滤列表,list转map「建议收藏」list去重,根据对象某个属性、某几个属性去重去除List中重复的StringListunique=list.stream().distinct().collect(Collectors.toList());去除List中重复的对象//Person对象publicclassPerson{privateStringid;…

    2022年5月9日
    400
  • Linux kworker 占用CPU过高

    Linux kworker 占用CPU过高先打开HTOPhtop如何按HK(大写)我们看到Kworker/0:0+events,下面参考下人家的回答什么是kworker?kworker表示进行“工作”(处理系统调用)的Linux内核进程。在进程列表中可以有多个:kworker/0:1在第一个CPU内核上kworker/1:1是一个,在第二个CPU内核上是一个,依此类推。为什么kworker占用您的CPU?…

    2026年3月6日
    5
  • MATLAB画图颜色渐变「建议收藏」

    MATLAB画图颜色渐变「建议收藏」原文(https://wenku.baidu.com/view/bf87a9d5804d2b160a4ec03f.html)1渐变1.1t=[linspace(0,2*pi)nan];x=sin(t);y=cos(2*t);z=sqrt(t);%所要绘制的曲线方程patch(x,y,z,z,’edgecolor’,’flat’,’facecolor’,’none’)vi…

    2022年5月31日
    277

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号