题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
#include<stdio.h>
int main(void)
{
char s[200];
int s1[200];
char l[200];
int len_s;
int len_l;
scanf("%[^\n]\n", &s);
scanf("%[^\n]", &l);
len_s = strlen(s);
len_l = strlen(l);
int i = 0;
int j = 0;
int k = 0;
int sig = 0;
for (i = 0; i < len_s; i++)
{
for (j = 0; j < len_l; j++)
{
if (s[i] == l[j])
{
k++;
}
}
if (k >= 1)
{
s1[i] = 1;
k = 0;
}
else
{
s1[i] = 0;
k = 0;
}
}
for (i = 0; i < len_s; i++)
{
if (s1[i] == 0)
{
sig = 1;
}
}
if (sig == 0)
{
printf("true");
}
else
{
printf("false");
}
return 0;
}
int main(void)
{
char s[200];
int s1[200];
char l[200];
int len_s;
int len_l;
scanf("%[^\n]\n", &s);
scanf("%[^\n]", &l);
len_s = strlen(s);
len_l = strlen(l);
int i = 0;
int j = 0;
int k = 0;
int sig = 0;
for (i = 0; i < len_s; i++)
{
for (j = 0; j < len_l; j++)
{
if (s[i] == l[j])
{
k++;
}
}
if (k >= 1)
{
s1[i] = 1;
k = 0;
}
else
{
s1[i] = 0;
k = 0;
}
}
for (i = 0; i < len_s; i++)
{
if (s1[i] == 0)
{
sig = 1;
}
}
if (sig == 0)
{
printf("true");
}
else
{
printf("false");
}
return 0;
}