题解 | #HJ81 字符串字符匹配#
字符串字符匹配
http://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
C语言版本
#include <stdio.h>
#include <stdbool.h>
int main() {
char S[201];
char T[201];
scanf("%s", S);
scanf("%s", T);
bool flagS[26] = {false};
for (int i = 0; i < strlen(S); i++) {
flagS[S[i]-'a'] = true;
}
bool flagT[26] = {false};
for (int i = 0; i < strlen(T); i++) {
flagT[T[i]-'a'] = true;
}
bool flag = true;
for (int i = 0; i < 26; i++) {
if (flagS[i] == true) {
if (flagT[i] != true) {
flag = false;
break;
}
}
}
if (flag) {
printf("true\n");
} else {
printf("false\n");
}
return 0;
}
Python版本
while True:
try:
S, T = input(), input()
if set(S) & set(T) == set(S):
print('true')
else:
print('false')
except:
break