Witam mam pytanko. Potrzebuje stworzyc w C++ kod na ciag Fibonacciego przy pomocy petli do while albo while. Czy ktos moze moglby mi go napisac?
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
http://wklej.org/id/996189/
#include <iostream>
using namespace std;
int main()
{
int ilosc = 0;
int suma = 0;
int x = 0;
cout << "Ile chcesz wyliczyc poczatkowych ciagow Fibonacciego?: ";
cin >> ilosc;
int *tablica = new int [ilosc];
tablica[0] = 0;
tablica[1] = 1;
cout << tablica[0] << ",";
while (x < ilosc-1)
{
x++;
suma = tablica[x] + tablica[x+1];
cout << suma << ",";
tablica[x+2] = suma;
}
delete [] tablica;
return 0;
}