This commit is contained in:
Oleksandr Hryshchenko 2021-03-07 00:21:48 +01:00
commit 7fdc695ece

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);
}