diff --git a/du1/program.c b/du1/program.c index b5dbf90..0ece4b3 100644 --- a/du1/program.c +++ b/du1/program.c @@ -1,38 +1,41 @@ -#include -#include +#include + +char change(char inp){ + if(inp >= 'A' && inp <= 'Z'){ + inp += 'a' - 'A'; + return inp; + } + else if(inp >= 'a' && inp <= 'z'){ + inp -= 'a' - 'A'; + return inp; + } +} int main(){ - int c = 0; - char text[256]; - while(1){ - char ch; - int num = 'a' - 'A'; - scanf("%c", &ch); - if(ch == EOF || ch == -1){ - break; - } - c++; - if(ch <= 'A' && ch >= 'Z'){ - ch += num; - c--; - } - else if(ch >= 'a' && ch <= 'z'){ - ch -= num; - c--; - } - text[c] = ch; - } - printf("%d\n", strlen(text)); - for(int i = 0; i < c; i++){ - if(text[i] != '\n'){ - printf("%c\n", text[i]); - } - else{ - printf("\n"); - } - - } - printf("%d\n", c); + char text[255]; + int num = 0; + + for(int i = 0; text[i] != EOF; i++){ + scanf("%c", &text[i]); + } + + int len = sizeof(text); + for(int i = 0; i < len; i++){ + if(text[i] == '\n') num += 1; + } + + for(int i = 0; text[i] != '\n'; i++){ + printf("%c\n", change(text[i])); + } + + for(int i = -1; i < num; i++){ + printf("\n"); + } + + printf("Počet riadkov: %d\n", num); + + return 0; } +