#include #include 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; }