zoukankan      html  css  js  c++  java
  • CodeForces

    字符串的处理

    统计已有字符的个数 和需求字符比较

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 
     5 using namespace std;
     6 
     7 int head[64];
     8 int text[64];
     9 char input[256];
    10 int main()
    11 {
    12     freopen("in.txt", "r", stdin);
    13     gets(input);
    14     for (int i = 0; i < strlen(input); i++)
    15     {
    16         if (input[i] >= 'a' && input[i] <= 'z')
    17         {
    18             head[input[i] - 'a']++;
    19         }
    20         else if ( input[i] >= 'A' && input[i] <= 'Z' )
    21         {
    22             head[input[i] - 'A'+26]++;
    23         }
    24     }
    25     gets(input);
    26     for (int i = 0; i < strlen(input); i++)
    27     {
    28         if (input[i] >= 'a' && input[i] <= 'z')
    29         {
    30             text[input[i] - 'a']++;
    31         }
    32         else if ( input[i] >= 'A' && input[i] <= 'Z' )
    33         {
    34             text[input[i] - 'A'+26]++;
    35         }
    36     }
    37     bool judge = true;
    38     for (int i = 0; i < 52; i++)
    39     {
    40         if (text[i] > head[i] )
    41         {
    42             judge = false;
    43             break;
    44         }
    45     }
    46     if (judge) printf("YES
    ");
    47     else printf("NO
    ");
    48 }
  • 相关阅读:
    poj1328
    xml入门简介--两天学会xml
    php的一些特殊用法
    数据结构(一)
    队列的 基本操作
    栈的 基本操作
    线性表----单链表
    线性表----顺序表
    数据结构
    链式队列
  • 原文地址:https://www.cnblogs.com/oscar-cnblogs/p/6329690.html
Copyright © 2011-2022 走看看