1084.Broken Keyboard
来源:互联网 发布:中甲联赛数据统计 编辑:程序博客网 时间:2024/06/05 01:51
【题意】
找到相对第一个字符串,第二个字符串少了的字符(需大写)
【思路】
用一个集合存下第二个字符串中的所有字符,然后对第一个字符串从前往后比对即可,碰到多余的字符要加入集合中以避免再次输出
#include <iostream>#include <string>#include <vector>#include <set>#include <algorithm>using namespace std;int main(int argc, char const *argv[]){string str[2];vector<char> broken;set<char> ss;cin >> str[0] >> str[1];for(int i=0; i<2; i++){transform(str[i].begin(),str[i].end(),str[i].begin(),::toupper);}for(int i=0; i<str[1].length(); i++){ss.insert(str[1][i]);}for(int i=0; i<str[0].length(); i++){if(ss.find(str[0][i])==ss.end()){ss.insert(str[0][i]);broken.push_back(str[0][i]);}}for(int i=0; i<broken.size(); i++){cout << broken[i];}system("pause");return 0;}
0 0
- PAT 1084. Broken Keyboard
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084.Broken Keyboard
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- Android Intent Action 大全
- iOS动画进阶(五)变换
- 站在巨人的肩膀上,C++开源库大全
- js分页工具
- 初探Golang顺序编程概念
- 1084.Broken Keyboard
- 智能家居,来年应该如何持续热度
- PHP mysql 中文乱码
- alter table在MSSQL中的用法
- Cocos2d-x3.3Final(1) ListView常用成员函数(C++)
- 1085.Perfect Sequence
- 基于hadoop的社交网络的分析
- 访问谷歌服务之hosts文件配置工具huhamhire-hosts
- Android Looper和Handler详解