题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
#include <stdio.h> #include <string.h> #include "stdbool.h" bool isShortInlong(char *longs ,char shortChar) { int len = strlen(longs); for (int i =0; i != len; i++) { if (longs[i] == shortChar) { return true; } } return false; } //暴力解决 int main() { char shortBuf[201]; //短串内容 char longBuf[201]; int len =0; int i =0; while (scanf("%s",shortBuf) != EOF) { scanf("%s",longBuf); len = strlen(shortBuf); for ( i =0; i != len; i++) { if (isShortInlong(longBuf , shortBuf[i]) == false) { printf("false"); break; //return 0; } } if (i == len) { printf("true"); } } }