1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课内】14.指针2/6-3 存在感.c

24 lines
496 B
C
Raw Normal View History

2024-12-04 02:28:21 +00:00
int frequency(char* paragraph, char* from, char* to) {
int cnt = 0;
int len = strlen(paragraph);
for (int i = 0; i < len; i++) {
if (paragraph[i] == from[0]) {
int flag = 1;
for (int j = 1; from + j <= to; j++) {
if (paragraph[i + j] != from[j]) {
flag = 0;
break;
}
}
if (flag) {
cnt++;
}
}
}
return cnt;
}