Skip to content

Instantly share code, notes, and snippets.

@Hajto
Created October 15, 2016 11:32
Show Gist options
  • Save Hajto/8281d9ab9f6159a4c7ae0c5e59846d7e to your computer and use it in GitHub Desktop.
Save Hajto/8281d9ab9f6159a4c7ae0c5e59846d7e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
//Wersja A
int main(){
char input[64];
double product = 1;
int iteration_count = 0;
printf("Wpisuj kolejno liczby naturalne dodatnie oddziel je enterami, gdy chcesz zakonczyc i policzyc srednia wpisz 'koniec'\n");
while( scanf("%s", &input) && strcmp("koniec",input) != 0 ){
double value = strtod(input, NULL);
if(value > 0){
product *= value;
iteration_count++;
} else {
printf("Liczba ujemna.. Podaj dodatnią\n");
}
}
printf("Suma: %lf, liczb: %d \n", product, iteration_count);
printf("test: %f \n", 1/5 );
printf("Test: %lf \n",pow(360000, 1/5));
printf("Wynik: %lf \n", pow(product, 1/iteration_count));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment