PTA(Advanced Level) 1092:To Buy or Not to Buy(C语言实现)
分析:乙级题目1039:到底买不买
添加链接描述
#include <stdio.h>
int main()
{
int flag[256]={0},i,miss=0,l1,l2;
char eva[1001]="",owner[1001]="";
gets(owner);
gets(eva);
for(i=0; owner[i]; i++)
flag[owner[i]]++;
l1=i;//owner的珠子长度
for(i=0; eva[i]; i++)
{
flag[eva[i]]--;
if(flag[eva[i]] < 0)//缺珠子
miss++;
}
l2=i;//eva的珠子长度
if(miss > 0)
printf("No %d",miss);
else
printf("Yes %d",l1-l2);
return 0;
}