From 4b8f51c1a182ec3c4149aed4914877044157ae5b Mon Sep 17 00:00:00 2001 From: Vladyslav Korzun Date: Fri, 17 Feb 2023 12:12:22 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'du1/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du1/program.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/du1/program.c b/du1/program.c index ea315d7..aceb113 100644 --- a/du1/program.c +++ b/du1/program.c @@ -2,34 +2,23 @@ #include #include int main(){ -int count = 0; int c = 0; +int count = 0; int riadok = 0; -int pop = 0; while(c != EOF){ c = getchar(); -if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')){ -if (c >= 'a' && c <= 'z' && count == 0){ -c = c - 32; -printf("%c", c); -count++; -riadok++; -} -if (c >= 'A' && c <= 'Z' && count == 0){ -c = c + 32; -printf("%c", c); -riadok++; -} -pop++; -} -else{ -if(c != 10 && pop == 0){ +if(islower(c)){ +c = toupper(c); printf("%c\n", c); riadok++; +count++; } -} -pop = 0; -count = 0; +if(isupper(c) && count == 0){ +c = tolower(c); +printf("%c\n", c); +riadok++; +} +count = 0; } printf("\nPočet riadkov: %d\n", riadok); return 0;