1092.To Buy or Not to Buy
来源:互联网 发布:informix sql 定义变量 编辑:程序博客网 时间:2024/05/01 08:55
【题意】
判断字符串1是否包含了字符串2所有的字符,是的话输出多余字符数,否则输出缺的字符数
【思路】
直接码即可
#include <iostream>#include <string>#include <map>using namespace std;int main(){string str[2];map<char, int> mm;for (int i = 0; i < 2; ++i){cin >> str[i];}for (auto i : str[0]){++mm[i];}int missCnt, extraCnt;missCnt = extraCnt = 0;for (auto i : str[1]){if (mm.find(i) != mm.end() && mm[i]){--mm[i];}else{++missCnt;}}if (missCnt){cout << "No " << missCnt;}else{for (auto i : mm){extraCnt += i.second;}cout << "Yes " << extraCnt;}system("pause");return 0;}
0 0
- 1092.To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1004. To Buy or Not to Buy
- 1004. To Buy or Not to Buy
- 1092. To Buy or Not to Buy (20)
- PAT A 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy (20)
- pat 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy(STL)
- 1092. To Buy or Not to Buy (20)
- 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy (20)
- jdbc相关文档
- linux常用命令集合
- 黑马程序员_图形用户界面GUI-基本操作
- 记忆化搜索——POJ 1088
- zend studio 安装时出现could not write value to key
- 1092.To Buy or Not to Buy
- Java设计模式——外观模式(门面模式)(Facade)
- HTML5之Canvas画圆形
- access 偏移注入 案例
- 1093.Count PAT's
- Java的ClassLoader
- 1094.The Largest Generation
- spring学习笔记13(注解@Autowired方式注入)
- 1095.Cars on Campus