mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +00:00
24 lines
496 B
C
24 lines
496 B
C
|
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;
|
||
|
}
|