首页 > 其他 > 详细

CodeForces - 43B Letter

时间:2017-01-21 00:45:04      阅读:415      评论:0      收藏:0      [点我收藏+]

字符串的处理

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

 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\n");
47     else printf("NO\n");
48 }

 

CodeForces - 43B Letter

原文:http://www.cnblogs.com/oscar-cnblogs/p/6329690.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!