Изменил(а) на 'du3/program.c'
This commit is contained in:
parent
d4364a3d88
commit
f194279a0c
@ -2,22 +2,46 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#define LINE_SIZE 10
|
||||
int main(){
|
||||
char riadok[LINE_SIZE];
|
||||
memset(riadok, 0,LINE_SIZE);
|
||||
char* r = fgets(riadok,LINE_SIZE,stdin);
|
||||
assert(r!=NULL);
|
||||
int r2 = atol(riadok);
|
||||
char* r;
|
||||
int r2;
|
||||
int stop = 0;
|
||||
char mass[LINE_SIZE];
|
||||
int i = 0;
|
||||
int x = 0;
|
||||
int vysl = 0;
|
||||
int counter = -1;
|
||||
int h = 0;
|
||||
while(stop == 0){
|
||||
r = fgets(riadok,LINE_SIZE,stdin);
|
||||
assert(r!=NULL);
|
||||
r2 = atol(riadok);
|
||||
mass[i] = r2;
|
||||
//printf("%d\n", r2);
|
||||
i++;
|
||||
if (r2 == 0){
|
||||
printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula.");
|
||||
//printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula.\n");
|
||||
stop++;
|
||||
}
|
||||
if(stop == 0){
|
||||
printf("%d", r2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
x = mass[0];
|
||||
//printf("%d\n", x);
|
||||
for(int j = i - 2; j > 0; j--){
|
||||
counter++;
|
||||
h = mass[j];
|
||||
//printf("%d ", h);
|
||||
if(j != 0){
|
||||
if(counter != 0){
|
||||
vysl += h * pow(x,counter);
|
||||
}
|
||||
else{
|
||||
vysl += h;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("Vysledok je:%d\n", vysl);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user