ValerianBenchea

Bac 2015

Jun 14th, 2023 (edited)
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. ///_____SUBIECTUL II 5_____
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int i, n, j, a[21][21];
  8.     cin>>n;
  9.     for(i=1; i<=n; i++)
  10.         cin>>a[1][i];
  11.     for(i=2; i<=n; i++)
  12.     {
  13.         for(j=2; j<=n; j++)
  14.             a[i][j]=a[i-1][j-1];
  15.         a[i][1]=a[i-1][n];
  16.  
  17.     }
  18.     for(i=1; i<=n; i++)
  19.     {
  20.         for(j=1; j<=n; j++)
  21.             cout<<a[i][j]<<" ";
  22.         cout<<endl;
  23.     }
  24.     return 0;
  25. }
  26.  
  27. ///_____SUBIECTUL III 3_____
  28. int Fibo(int n)
  29. {
  30.     int t1=1, t2=1, term;
  31.     if(n==1|| n==2)
  32.         return 1;
  33.     int cnt=2;
  34.     while(true)
  35.     {
  36.         term=t1+t2;
  37.         if(term%2)
  38.             cnt++;
  39.         if(cnt==n)
  40.             return term;
  41.         t1=t2;
  42.         t2=term;
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment