当前位置:网站首页>B1029 旧键盘
B1029 旧键盘
2022-07-27 05:01:00 【叶辰 .】
1029 旧键盘 (20 分)
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。
输入格式:
输入在 2 行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过 80 个字符的串,由字母 A-Z(包括大、小写)、数字 0-9、以及下划线 _(代表空格)组成。题目保证 2 个字符串均非空。
输出格式:
按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有 1 个坏键。
输入样例
7_This_is_a_test
_hs_s_a_es
输出样例
7TI
题目分析:
- 使用toupper函数将小写字母转换为大写字将未找到的字母全存入s3中
- 遍历s3去重
代码如下:
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1,s2,s3;
cin>>s1>>s2;
for(int i=0;i<s1.size();i++){
if(s2.find(s1[i])==string::npos&&s2.find(toupper(s1[i]))==string::npos){
s3+=toupper(s1[i]);//toupper函数将小写字母转换为大写字母
}
}
for(int i=0;i<s3.size();i++){
string s=s3.substr(0,i);//建立字符串s3[0,i)
if(s.find(s3[i])==string::npos){
cout<<s3[i];
}
}
//也可以使用字符数组来存,先排序,后去重unique(),遍历上s3,按照原有顺序打印
return 0;
}
边栏推荐
- Error: cannot read properties of undefined (reading 'then')
- "Photoshop2021 tutorial" adjust the picture to different aspect ratio
- "Photoshop2021 tutorial" align and distribute to make dot patterns
- Use of collection framework
- Create datasource using Druid connection pool
- 抽卡程序模拟
- Li Kou achieved the second largest result
- JVM上篇:内存与垃圾回收篇十--运行时数据区-直接内存
- 树莓派rtmp推流本地摄像头图像
- Why is count (*) slow
猜你喜欢

Jmeter 界面如何汉化?

Constraints of MySQL table

How to copy Photoshop layers to other documents

34. Analyze flexible.js

How to sinicize the JMeter interface?

OFDM 16 lecture 2-ofdm and the DFT

Use of collection framework

MySQL storage engine and its differences

Dialog introduction

Translation of robot and precise vehicle localization based on multi sensor fusion in diverse city scenes
随机推荐
Counting Nodes in a Binary Search Tree
Install pyGame
Solution and principle analysis of feign call missing request header
树莓派输出PWM波驱动舵机
Svn usage details
"Photoshop2021 tutorial" adjust the picture to different aspect ratio
节流函数的demo——正则表达式匹配
Another skill is to earn 30000 yuan a month+
Customize the viewport height, and use scrolling for extra parts
[untitled] I is circularly accumulated under certain conditions. The condition is usually the length of the loop array. When it exceeds the length, the loop will stop. Because the object cannot judge
集合框架的使用
Basic operation of vim
一、MySQL基础
34. Analyze flexible.js
[acwing] solution to the 61st weekly match
动态内存函数的介绍(malloc free calloc realloc)
JVM上篇:内存与垃圾回收篇十四--垃圾回收器
Could not autowire.No beans of ‘userMapper‘ type found.
老子云携手福昕鲲鹏,首次实现3D OFD三维版式文档的重大突破
SSM framework integration