Aktualizovat du1/program.c
This commit is contained in:
parent
70f3bc4f57
commit
521c8e15e6
@ -1,57 +1,37 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int GetTypZnaku(int vstup);
|
||||
|
||||
int main()
|
||||
{
|
||||
int vstup = 0;
|
||||
int pocetRiadkov = 0;
|
||||
while (1)
|
||||
{
|
||||
//helper lok. premeny
|
||||
bool mozeBytPrinted = true;
|
||||
int vysChar = 0;
|
||||
int vstup = getchar();
|
||||
if (vstup == EOF) {break;}
|
||||
|
||||
//scanning faza programu
|
||||
vstup = getchar();
|
||||
vysChar = vstup;
|
||||
|
||||
if (vstup == EOF) { break;} //ak EOF (End Of File), resp. koniec suboru
|
||||
|
||||
if (vstup == '\n') // ak NewLine char, resp. koniec riadku
|
||||
if (vstup == '\n')
|
||||
{
|
||||
pocetRiadkov += 1;
|
||||
putchar(vstup);
|
||||
}
|
||||
//ak vstup == malemu pismenu
|
||||
else if (GetTypZnaku(vstup) == 0)
|
||||
else if (vstup == '\r')
|
||||
{
|
||||
vysChar = toupper(vstup);
|
||||
continue;
|
||||
}
|
||||
//ak vstup == velke pismeno
|
||||
else if (GetTypZnaku(vstup) == 1)
|
||||
else if (islower(vstup) != 0)
|
||||
{
|
||||
vysChar = tolower(vstup);
|
||||
putchar(toupper(vstup));
|
||||
}
|
||||
//ak to nie je neviditelny char (resp. riadiaci/control) a NIE je NewLine
|
||||
else if (GetTypZnaku(vstup) == 2 && vstup != '\n')
|
||||
else if (isupper(vstup) != 0)
|
||||
{
|
||||
mozeBytPrinted = false;
|
||||
putchar(tolower(vstup));
|
||||
}
|
||||
else if (vstup >= 32 && vstup <= 126)
|
||||
{
|
||||
putchar(vstup);
|
||||
}
|
||||
|
||||
//output vidtelnehok charakteru
|
||||
if (mozeBytPrinted) { putchar(vysChar);}
|
||||
}
|
||||
printf("%d\n", pocetRiadkov);
|
||||
printf("\nLines_count: %d\n", pocetRiadkov);
|
||||
return 0;
|
||||
}
|
||||
int GetTypZnaku(int vstup)
|
||||
{
|
||||
if (islower(vstup) != 0) { return 0;}
|
||||
if (isupper(vstup) != 0) { return 1;}
|
||||
if (iscntrl(vstup) != 0) { return 2;}
|
||||
return -1;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user