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