#include <stdio.h>
#include <stdlib.h>
void licz(int i, int start, int krok, int suma, int iloczyn, int iloscElementow, unsigned int elementy[]) {
int index = (start + i * krok);
if (index >= iloscElementow) {
return;
}
printf("\n");
printf("Index: %d, Wartosc elementu: %d", index, elementy[index]);
suma += elementy[index];
iloczyn *= elementy[index];
printf("\n");
printf("Suma: %d, Iloczyn: %d", suma, iloczyn);
licz(i + 1, start, krok, suma, iloczyn, iloscElementow, elementy);
}
void wczytajElementy(int i, int iloscElementow, unsigned int elementy[]) {
if (i == iloscElementow) {
int start, krok;
printf("Podaj liczbę start z zakresu 0-1000: ");
scanf_s (" %d", &start);
if (start < 0 || start > 1000) {
printf("Podałeś element start z poza zakresu!");
exit(0);
}
printf("Podaj liczbę kroku z zakresu 1-1000: ");
scanf_s (" %d", &krok);
if (krok < 1 || krok > 1000) {
printf("Podałeś element krok z poza zakresu!");
exit(0);
}
printf("Obliczenie sumy oraz iloczynu elementów o id:");
licz(0, start, krok, 0, 1, iloscElementow, elementy);
return;
}
int t = 0;
printf("Podaj %d element z zakresu 1-1000: ", i);
scanf_s (" %d", &t);
if (t < 1 || iloscElementow > 1000) {
printf("Podałeś element z poza zakresu!");
exit(0);
}
elementy[i] = t;
wczytajElementy(i + 1, iloscElementow, elementy);
}
int main() {
unsigned int iloscElementow = 0;
unsigned int* elementy = new unsigned int[iloscElementow];
printf("Podaj ile liczb chcesz wprowadzic: ");
scanf_s (" %d", &iloscElementow);
wczytajElementy(0, iloscElementow, elementy);
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}