22.2
This commit is contained in:
parent
cca3e0833b
commit
023da99602
@ -1,32 +1,26 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int c;
|
|
||||||
int lines_count = 0;
|
int lines_count = 0;
|
||||||
|
int c;
|
||||||
|
|
||||||
while ((c = getchar()) != EOF) {
|
while ((c = getchar()) != EOF) {
|
||||||
// Check if the character is a lowercase letter
|
if (islower(c)) {
|
||||||
if (c >= 'a' && c <= 'z') {
|
putchar(toupper(c));
|
||||||
// Convert lowercase to uppercase
|
} else if (isupper(c)) {
|
||||||
c = c - 'a' + 'A';
|
putchar(tolower(c));
|
||||||
|
} else {
|
||||||
|
putchar(c);
|
||||||
|
if (c == '\n') {
|
||||||
|
lines_count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Check if the character is an uppercase letter
|
|
||||||
else if (c >= 'A' && c <= 'Z') {
|
|
||||||
// Convert uppercase to lowercase
|
|
||||||
c = c - 'A' + 'a';
|
|
||||||
}
|
|
||||||
// Check if the character is an end of line
|
|
||||||
else if (c == '\n') {
|
|
||||||
// Increment line count
|
|
||||||
lines_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output the character
|
|
||||||
putchar(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the number of lines read
|
printf("Počet načítaných riadkov: %d\n", lines_count);
|
||||||
printf("Lines count: %d\n", lines_count);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user