题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
#include<stdio.h> #include<string.h> int main() { char t[201], s[201]; int tTimes[26] = {0}; int sTimes[26] = {0}; scanf("%s", t); scanf("%s", s); for(int i = 0; i < strlen(t); i++){ tTimes[t[i] - 'a']++; } for(int i = 0; i < strlen(s); i++){ sTimes[s[i] - 'a']++; } int flag = 1; for(int i = 0; i < 26; i++){ if(sTimes[i] == 0 && tTimes[i] != 0){ flag = 0; break; } } if(flag == 1){ printf("true"); }else{ printf("false"); } }