81 lines
1.8 KiB
C
81 lines
1.8 KiB
C
//
|
|
// Created by bruno on 3/11/24.
|
|
//
|
|
|
|
#include "funkcie.h"
|
|
#include "stdio.h"
|
|
|
|
void greet(char meno[]) {
|
|
printf("Ahoj %s, vitaj na Adlerke.\n", meno);
|
|
}
|
|
|
|
int obsahObdlznika(int w, int h) {
|
|
return w * h;
|
|
}
|
|
|
|
int funkcie(void) {
|
|
greet("Jožo");
|
|
greet("Fero");
|
|
greet("Viki");
|
|
int a = 10;
|
|
int b = 5;
|
|
printf("Zadaj strany obdĺžnika (a b):");
|
|
scanf("%d %d", &a, &b);
|
|
printf("Obdĺžnik so stranami %d a %d má obsah %d.\n", a, b, obsahObdlznika(a, b));
|
|
return 0;
|
|
}
|
|
|
|
int containscharacter(char character, char characters[]) {
|
|
int i = 0;
|
|
while (characters[i]) {
|
|
if (character == characters[i]) {
|
|
return 1;
|
|
}
|
|
i++;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int jeCislo(char znak) {
|
|
return znak > 47 && znak < 58;
|
|
}
|
|
|
|
void toLowercase(char *instring) {
|
|
int i = 0;
|
|
while (instring[i] != '\n') {
|
|
if (instring[i] > 64 && instring[i] < 91) {
|
|
instring[i] += 32;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
int counterChars() {
|
|
char instring[256];
|
|
printf("Zadaj max 255 znakový reťazec.");
|
|
fgets(instring, 255, stdin);
|
|
toLowercase(instring);
|
|
char samohlasky[] = "aeiou";
|
|
char spoluhlasky[] = "bmprsvzfhgkdtnlcj";
|
|
|
|
int cislaCnt = 0;
|
|
int samohlaskyCnt = 0;
|
|
int spoluhlaskyCnt = 0;
|
|
|
|
int i = 0;
|
|
while (instring[i] != '\n') {
|
|
if (jeCislo(instring[i])) {
|
|
cislaCnt++;
|
|
} else if (containscharacter(instring[i], samohlasky)) {
|
|
samohlaskyCnt++;
|
|
} else if (containscharacter(instring[i], spoluhlasky)) {
|
|
spoluhlaskyCnt++;
|
|
}
|
|
i++;
|
|
}
|
|
printf("\"%s\" je dlhý %d znakov, %d z nich sú čísla, %d z nich sú samohlásky, %d z nich sú spoluhlásky a zvyšných je %d.\n",
|
|
instring, i, cislaCnt, samohlaskyCnt, spoluhlaskyCnt, i - cislaCnt - samohlaskyCnt - spoluhlaskyCnt);
|
|
|
|
return 0;
|
|
}
|