-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindstring.cpp
More file actions
33 lines (29 loc) · 766 Bytes
/
Findstring.cpp
File metadata and controls
33 lines (29 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdlib.h>
#include <stdio.h>
#include <string>
using namespace std;
int main()
{
string a = "abcdefghijk";
string b = "bdhij";
int help[26] = {0};
int num = 0;
for (int i = 0; i < b.length(); i++) {
int index = b[i] - 'a';
if (help[index] == 0) {
help[index] = 1;
num++;
}
}
for (int j = 0; j < a.length(); j++) {
int index = a[j] - 'a';
if (help[index] == 1) {
help[index] = 0;
num--;
}
}
if (num == 0)
printf("true\n");
else
printf("false\n");
}