当前位置: 代码迷 >> 综合 >> Alphabet Cookies
  详细解决方案

Alphabet Cookies

热度:94   发布时间:2023-10-18 05:00:33.0

 Alphabet Cookies


题目描述

Kitty likes cookies very much, and especially the alphabet cookies. Now, she get some alphabet cookies, and she wants to select some of them to spell some words.

The easy task for you, is to determine that whether she can spell the word she wants.

输入

The input contains several test cases.

Each test case contains an integer N ( 0 < N ≤ 100 ) in a line.

And followed a line with N capital letters, means the cookies she has.

Then the last line is a word with capital letters. And the word’s length isn’t more than N.

输出

 One word for each test case. If she can spell the word by these letters, please output “Yes”, nor output “No”.

样例输入

7ARDHPYPHAPPY6ARDHPYHAPPY

样例输出

YesNo

题意:

给出现在拥有的饼干数,问使用这些饼干是否可以拼成下面的字母

解题思路:
水题,暴力比较就好

代码如下:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<algorithm>
using namespace std;
int main()
{int i,j;int aa[100];char ch[1000];char str[1000];int n,m;while(~scanf("%d",&n)){scanf("%s %s",str,ch);m=0;int len=strlen(ch);for(i=0;i<n;i++){for(j=0;j<len;j++){if(str[i]==ch[j]){ch[j]='#';m++;break;}}}if(m<len){printf("No\n");}else printf("Yes\n");}return 0;
}



  相关解决方案