GerexD

dinamikus-betus

Feb 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,a[40],b[40],c[40],d[40];
  8. cout<<"N ";cin>>n;
  9. a[1]=1;b[1]=1;c[1]=1;d[1]=1;
  10. for(int i=2;i<=n;i++)
  11. {
  12. a[i]=a[i-1]+c[i-1]+d[i-1];
  13. b[i]=b[i-1]+c[i-1]+d[i-1];
  14. c[i]=a[i-1]+b[i-1]+c[i-1]+d[i-1];
  15. d[i]=a[i-1]+b[i-1]+c[i-1]+d[i-1];
  16.  
  17. }
  18. cout<<a[n]+b[n]+c[n]+d[n];
  19. return 0;
  20. }
Add Comment
Please, Sign In to add comment