Files
Laboratori-TDP/TemiEsame/countAndPrint.c
2024-03-22 17:14:57 +01:00

41 lines
675 B
C

#include <stdio.h>
#include <string.h>
#include <ctype.h>
int isVocal(char c) {
char * vowels = "aeiou";
c = tolower(c);
return strchr(vowels, c) != NULL;
}
void countAndPrint(char str[], int n) {
int l = strlen(str), v, s = 0;
for (int i = 0; i < l - n; i++) {
v = 0;
for (int j = i; j < i + n; j++) {
if (isVocal(str[j])) {
v++;
}
}
if (v == 2) {
s++;
for (int j = i; j < i + n; j++)
putchar(str[j]);
putchar('\n');
}
}
printf("%d", s);
}
int main() {
countAndPrint("forExample",4);
return 0;
}