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;
}



 posted on 2017-05-05 19:15  拖延症重症患者~  阅读(184)  评论(0编辑  收藏  举报