Advertisement
youuw

6.c

Nov 29th, 2021
1,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. /*
  2. Zadanie 6. Napisz program generujacy ciag n poczatkowych liczb Fibonacciego. Liczby
  3. powinny by¢ umieszczone w tablicy o stosownym rozmiarze. a nastepnie wyswietlone
  4. na ekranie monitora.
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. int main(int argc, char **argv) {
  10.  
  11.     int size;
  12.     printf("podaj ilosc liczb w ciagu\n"); //wyswietlenie komunikatu
  13.     scanf("%d", &size); //wprowadzenie zmiennych
  14.     int fib[size];
  15.     for(int x = 0; x<size;x++) {
  16.         fib[x] = x>=2?(fib[x-2] + fib[x-1]):1;
  17.         printf("%d ", fib[x]);
  18.     }
  19.  
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement