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

是,则输出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. HDFS核心设计

    一.HDFS核心设计 数据块(block) 数据块是HDFS上最基本的存储单位 HDFS块默认大小为128M         对块进行抽象会带来的好处 一个小文件的大小可以大于网络中任意一个磁盘的容量 ...

  2. 极限编程核心价值:简单(Simplicity)

    写在前面 在编写 ASP.NET Core 项目时,深感项目设计的无力感,在软件设计方面我还有很长的路要走.我一直以来都把代码当作一种艺术的存在,认为自己是个"艺术家",其实就是个 ...

  3. HTML DOM item() 方法

    一直不知道javascript还有类似jQ里面eq()的函数,原来原生javascript的item()有类似功能: 由于是原生javascript,先补习下children和childNodes的区 ...

  4. Linux第三课——目录操作

    ls 列出目录下的文件及子目录 ls -l 以列表的方式显示详细信息 ls -a 显示所有的 包括隐藏文件 ls -A 显示除了 . ..以外的任何文件 ls -i 显示文件的节点号 ls --col ...

  5. PHP中全局变量global和$GLOBALS[]的区别分析

    $GLOBALS['var']是外部的全局变量本身,global $var是外部$var的同名引用或者指针     一.举例比较 例一: 复制代码 代码如下: <?php $var1 = 1; ...

  6. 5、JUC--实现 Callable 接口

    Callable接口  Java 5.0 在 java.util.concurrent 提供了一个新的创建执行 线程的方式:Callable 接口  Callable 接口类似于 Runnable ...

  7. Android安全测试

  8. OpenCV——Harr特征

  9. Android 绘图时实现双缓冲

    一.双缓冲技术原理: 在内存中创建一片内存区域,把将要绘制的图片预先绘制到内存中,在绘制显示的时候直接获取缓冲区的图片进行绘制.更具体一点来说:先通过setBitmap方法将要绘制的所有的图形绘制到一 ...

  10. 创建一个目录的软连接ln -s和打印当前目录pwd的一个知识点

    创建一个目录的软连接,比如我在家目录下创建一个/data/www/的软连接,如下 # cd ~ # ln -s /data/www hehe       #这里一定要注意顺序哈哈 然后当我进入hehe ...