zoukankan      html  css  js  c++  java
  • Alphabet Cookies

     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
    ");
            }else printf("Yes
    ");
        }
        return 0;
    }
    



  • 相关阅读:
    CentOS7安装MySQL5.7
    python基础 元组操作
    初识Python Python的历史(转)
    Python基础 基本数据类型
    createEvent 流沙
    GetLogicalDriveStringS获取驱动器根路径 流沙
    监控文件系统用得到的API 流沙
    Windows I/O 操作CreateFile 流沙
    脚本加入域 流沙
    WMI事件 流沙
  • 原文地址:https://www.cnblogs.com/lanaiwanqi/p/10445743.html
Copyright © 2011-2022 走看看