31 lines
564 B
C
31 lines
564 B
C
#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);
|
|
}
|