Merge branch 'master' of git.kemt.fei.tuke.sk:oh735kh/pvjc21

Merge request
This commit is contained in:
Oleksandr Hryshchenko 2021-03-07 00:33:30 +01:00
commit 0cd5b2c0e5
2 changed files with 49 additions and 13 deletions

View File

@ -1,14 +1,17 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <string.h>
int main (){ int main (){
char c[100]; char c[100];
char musor; char musor;
int counter = 0; int counter = 0;
fgets(c, 100, stdin);
musor = getchar();
while(fgets(c, 100, stdin) != NULL){ while(fgets(c, 100, stdin) != NULL){
if(strlen(c) == 2){ if(strlen(c) == 1){
putchar (c[0]);
counter++;
}
else if(strlen(c) == 2){
if (c[0] >= 'a' && c[0] <= 'z'){ if (c[0] >= 'a' && c[0] <= 'z'){
putchar (c[0] - 'a' + 'A'); putchar (c[0] - 'a' + 'A');
printf ("\n"); printf ("\n");
@ -23,21 +26,24 @@ int main (){
putchar (c[0]); putchar (c[0]);
counter++; counter++;
} }
fgets(c, 100, stdin);
musor = getchar();
} }
else{ else{
for(int i = 0; i < 100; i++){ for(int i = 0; i < 100; i++){
if(c[i] == '\n') break; if(c[i] == '\n' || c[i] == '\0') break;
if(isupper(c[i])) if(isupper(c[i])) {
printf(tolower(c[i])); printf("%c", tolower(c[i]));
}
else if(islower(c[i])) else if(islower(c[i]))
printf(toupper(c[i])); printf("%c", toupper(c[i]));
else else
printf(c[i]); printf("%c", c[i]);
}
if(strchr(c, '\n') != NULL){
printf("\n");
counter++;
} }
} }
//counter++; memset(c, '\0', 100);
} }
printf("\nPočet riadkov: %d\n",counter); printf("\nPočet riadkov: %d\n",counter);

30
program.c Normal file
View File

@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main () {
char* BMW = (char*) calloc (100, sizeof(char));
int x;
int counter;
int numbers [100];
for (int i = 0; fgets(BMW, 100, stdin) != NULL; i++){
if (!strcmp("\n", BMW) || !strcmp(" ", BMW)) {
counter = i;
break;
}
if (i == 0){
x = atoi (BMW);
}
else {
numbers [i] = atoi [BMW];
}
}
int result = 0;
while (counter > 0){
result += pow (x, counter -1) * numbers [counter];
counter --;
}
printf ("Vysledok je: ");
printf ("%d\n", result);
}