给出两个字符串,判断第二个字符串中的字符是否都出现在第一个中。

是,则输出Yes,以及多余的字符的个数。

否,则输出No,以及缺失的个数。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
const int maxn=+;
const int maxbeads=;
int numshop[maxbeads];
int numeva[maxbeads];
int vis[maxbeads];
int main()
{
char shop[maxn],eva[maxn];
scanf("%s %s",shop,eva);
int len1=strlen(shop);
int len2=strlen(eva);
char ch;
memset(numshop,,sizeof(numshop));
memset(numeva,,sizeof(numeva));
memset(vis,,sizeof(vis));
for(int i=;i<len1;i++){
ch=shop[i];
if(''<=ch&&ch<=''){
numshop[ch-'']++;
}
else if('a'<=ch&&ch<='z'){
numshop[ch-'a'+]++;
}
else if('A'<=ch&&ch<='Z'){
numshop[ch-'A'+]++;
} }
for(int i=;i<len2;i++){
ch=eva[i];
if(''<=ch&&ch<=''){
numeva[ch-'']++;
vis[ch-'']=;
}
else if('a'<=ch&&ch<='z'){
numeva[ch-'a'+]++;
vis[ch-'a'+]=;
}
else if('A'<=ch&&ch<='Z'){
numeva[ch-'A'+]++;
vis[ch-'A'+]=;
} }
bool flag=true;
int left=,miss=;
for(int i=;i<maxbeads;i++){
if(!vis[i]){
left+=numshop[i];
continue;
}
if(numshop[i]>=numeva[i]){
left+=numshop[i]-numeva[i];
}
else{
miss+=numeva[i]-numshop[i];
flag=false;
}
}
if(flag)
printf("Yes %d",left);
else
printf("No %d",miss);
return ;
}

1092. To Buy or Not to Buy (20)-map的更多相关文章

  1. 1092 To Buy or Not to Buy (20 分)

    1092 To Buy or Not to Buy (20 分) Eva would like to make a string of beads with her favorite colors s ...

  2. pat 1092 To Buy or Not to Buy(20 分)

    1092 To Buy or Not to Buy(20 分) Eva would like to make a string of beads with her favorite colors so ...

  3. PAT 1092 To Buy or Not to Buy

    1092 To Buy or Not to Buy (20 分)   Eva would like to make a string of beads with her favorite colors ...

  4. poj1092. To Buy or Not to Buy (20)

    1092. To Buy or Not to Buy (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  5. PAT1092:To Buy or Not to Buy

    1092. To Buy or Not to Buy (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  6. PAT_A1092#To Buy or Not to Buy

    Source: PAT A1092 To Buy or Not to Buy (20 分) Description: Eva would like to make a string of beads ...

  7. PAT (Advanced Level) Practise - 1092. To Buy or Not to Buy (20)

    http://www.patest.cn/contests/pat-a-practise/1092 Eva would like to make a string of beads with her ...

  8. 1092. To Buy or Not to Buy (20)

    Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy ...

  9. PAT Advanced 1092 To Buy or Not to Buy (20) [Hash散列]

    题目 Eva would like to make a string of beads with her favorite colors so she went to a small shop to ...

  10. PAT (Advanced Level) 1092. To Buy or Not to Buy (20)

    简单题. #include<cstdio> #include<cstring> ; char s1[maxn],s2[maxn]; ]; ]; int main() { sca ...

随机推荐

  1. 团队作业——Beta冲刺3

    团队作业--Beta冲刺 冲刺任务安排 杨光海天 今日任务:浏览详情界面的开发 明日任务:浏览详情界面的开发 吴松青 今日任务:与队长一同进行图片详情的开发,接触了一些自己没接触过的知识点并向队友学习 ...

  2. (一)SSO之CAS框架通俗原理

    版权声明:本文为博主原创文章.转载请标明出处. https://blog.csdn.net/lovesummerforever/article/details/36068249 SSO统一验证     ...

  3. sql 一个表的字段更新至另一个字段的方法

    update Lc_Taxs set TaxMember = convert(int,Lc_Taxs2.TaxNo)  from Lc_Taxs a,(select * from Lc_Taxs ) ...

  4. vSphere虚拟化管理平台的功能

    VMware vSphere® 提供全球领先的虚拟化平台,用于构建云计算基础架构. vSphere 有哪些功能 强大的计算能力 虚拟化 x86 服务器资源并将其聚合成逻辑池,用于分配多个工作负载. 网 ...

  5. leetcode322—Coin Change

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  6. robotframe 自定义开发库

    site-packages(这个路径一定要在系统path路径中)下面创建一个UserDefineLibrary文件夹:目录结构如下 ---- ----- UserDefineLibrary __ in ...

  7. Android DatePickerDialog使用案例

    DatePickerDialog提供了一个弹出的Dialog供用户选择日期. 在这里分享一下其使用方法,效果图如下: DatePickerActivity.java package com.yw.my ...

  8. java中线程的几种状态和停止线程的方法

    1.线程的状态图 需要注意的是:线程调用start方法是使得线程到达就绪状态而不是运行状态 2.停止线程的两种方法 1)自然停止:线程体自然执行完毕 2)外部干涉:通过线程体标识 1.线程类中定义线程 ...

  9. 关于C#中async/await中的异常处理(下)-(转载)

    上一篇文章里我们讨论了某些async/await的用法中出现遗漏异常的情况,并且谈到该如何使用WhenAll辅助方法来避免这种情况.WhenAll辅助方法将会汇总一系列的任务对象,一旦其中某个出错,则 ...

  10. 怎样让oracle实验本在不做实验时性能提升——win7下举例

    怎样让oracle实验本在不做实验时性能提升--win7下举例 型号:ThinkPad E431 系统:WIN7 实验使用的笔记本不使用数据库时.建议将oracle关闭,使其释放占用的资源. orac ...