feat: Initial commit
This commit is contained in:
40
TemiEsame/countAndPrint.c
Normal file
40
TemiEsame/countAndPrint.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user