submit15
This commit is contained in:
parent
0fa3a58d5c
commit
ba6dfb22e2
@ -3,9 +3,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#define SIZE_OF_ARRAY 100
|
||||
#define LINE_SIZE 2
|
||||
|
||||
double powering(double, int);
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -32,16 +29,14 @@ int main()
|
||||
return 0;
|
||||
}
|
||||
for(int j=1; j<counter; j++){
|
||||
double true_power=powering(array_of_numbers[0],(counter-j)-1);
|
||||
result_of_main += array_of_numbers[j]*true_power;
|
||||
result_of_main += array_of_numbers[j]*pow(array_of_numbers[0],(counter-j)-1);
|
||||
}
|
||||
printf("Vysledok je: %.2f\n",round(result_of_main * 100) / 100);
|
||||
return 0;
|
||||
}
|
||||
int reading_input(double *number){
|
||||
char buffer[SIZE_OF_ARRAY];
|
||||
char *fgets_result = fgets(buffer,SIZE_OF_ARRAY,stdin);
|
||||
if(fgets_result==NULL){
|
||||
if(fgets(buffer,SIZE_OF_ARRAY,stdin)==NULL){
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -65,11 +60,5 @@ int reading_input(double *number){
|
||||
*number=atof(buffer);
|
||||
return 1;
|
||||
}
|
||||
double powering(double number, int counter){
|
||||
double result=1;
|
||||
for(int i=0; i<counter; i++){
|
||||
result =result * number;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user