题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
#include <stdio.h> #include <string.h> #define MAX 200 int main(){ char arr1[MAX] = {0}; char arr2[MAX] = {0}; fgets(arr1, sizeof(arr1), stdin); fgets(arr2, sizeof(arr1), stdin); arr1[strlen(arr1) - 1] = '\0'; arr1[strlen(arr2) - 1] = '\0'; int len1 = strlen(arr1); int len2 = strlen(arr2); int flage = 0; for(int i = 0; i < len1; i++){ for(int j = 0; j < len2; j++){ if(arr1[i] == arr2[j]){ flage++; break; } } } if(flage == len1) printf("true"); else printf("false"); return 0; }