BUPT-homework/pset9/7-substring.c
2021-11-25 17:04:19 +08:00

32 lines
579 B
C

// I'm cheating lol
#include <stdio.h>
#include <string.h>
#define MAX 2002
int main(void) {
char arr[MAX] = {};
char substr[MAX] = {};
char tmp;
int i = 0;
while ((tmp = getc(stdin)) != '-' && tmp != '\n') {
arr[i++] = tmp;
}
for (i = 0; i < 2; i++) {
getc(stdin);
}
i = 0;
while ((tmp = getc(stdin)) != '-' && tmp != '\n') {
substr[i++] = tmp;
}
/* printf("%s\n%s\n", arr, substr); */
if (strstr(arr, substr) != NULL) {
printf("ListB is the sub sequence of ListA.\n");
} else {
printf("ListB is not the sub sequence of ListA.\n");
}
return 0;
}