school/lepsiznak.c

31 lines
522 B
C
Raw Normal View History

2023-12-18 14:54:52 +01:00
//
// Created by bruno on 12/11/23.
//
#include "lepsiznak.h"
#include "stdio.h"
2024-01-22 14:41:15 +01:00
void invertcase(int *c) {
if (*c >= 'a' && *c <= 'z') {
2023-12-18 14:54:52 +01:00
*c -= 0x20;
2024-01-22 14:41:15 +01:00
} else if (*c >= 'A' && *c <= 'Z') {
2023-12-18 14:54:52 +01:00
*c += 0x20;
}
}
2024-01-22 14:41:15 +01:00
int lepsiznak() {
2023-12-18 14:54:52 +01:00
int c;
int pocet = 0;
const int koniec = 'k';
2024-01-22 14:41:15 +01:00
while ((c = getchar()) != koniec) {
2023-12-18 14:54:52 +01:00
invertcase(&c);
putchar(c);
pocet++;
}
printf("\nVydržal si %d znakov pred tým, ako si napísal %c.\n", pocet, koniec);
return 0;
}