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

是,则输出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. 嵌入式开发板LInux更新系统、安装软件、下载资源碰到的问题

    CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none 先同步系统时间 shell 输入命令 date 如果显示的时间跟你本地时间不一样,先设 ...

  2. Windows10下python3.5的sklearn库安装

    具体安装方法参考https://blog.csdn.net/HYDMonster/article/details/79766086 但是注意的是,http://www.lfd.uci.edu/~goh ...

  3. div+css ie6图片之间有间隙的问题

    图片转换为快级元素就解决了 img{display:block;} 也可设置img属性img{vertical-align:top;}

  4. SpringMVC之ajax+select下拉框交互常用方式

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. 如何快速找到某个研究领域的所有SCI期刊

    https://www.toutiao.com/a6624332265285485060/?tt_from=dingtalk&utm_campaign=client_share&tim ...

  6. OpenCV——归一化函数normalize

    函数原型: void cv::normalize(InputArry src,InputOutputArray dst,double alpha=1,double beta=0,int norm_ty ...

  7. grunt项目构建工具

    JS项目构建工具Grunt实践 一:下面来介绍下如何用grunt合并,压缩js文件.    大概步骤有如下:     1. 新建文件夹相对应的项目 比如文件名叫:gruntJs      2. 新建文 ...

  8. 使用XMing+putty运行linux图形界面程序

    起因接下去的工作要作一些数值模拟,于是到师兄的工作站上开了个帐号.工作站运行的是RHEL4,要说远程SSH,就算是FTerm也足够胜任,不过,因为我要用的查看计算结果的软件需要使用图形界面,这一点就比 ...

  9. 20155233 《网络对抗技术》EXP3 免杀原理与实践

    正确使用msf编码器,msfvenom生成如jar之类的其他文件,veil-evasion,自己利用shellcode编程等免杀工具或技巧 使用msf编码器生成jar包 输入命令msfvenom -p ...

  10. 20155237 2016-2017-2 《Java程序设计》第十周学习总结

    20155237 2016-2017-2 <Java程序设计>第十周学习总结 教材学习内容总结 计算机网络,是指分布在不同地理区域的计算机用通信线路互连起来的一个具有强大功能的网络系统.网 ...