fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. const int N = 220;
  5. int ctrl = 0;
  6. div_t t;
  7. void add(int a[N], int b[N], int c[N]){
  8. memset(c, 0, sizeof(int)*N);
  9. int i = 0;
  10. for(i = N - 1; i >= 0; i--){
  11. if(t.quot){
  12. c[i]++;
  13. if(i < ctrl) ctrl = i;
  14. }
  15. t = div((c[i] + a[i] + b[i]),10);
  16. c[i] = t.rem;
  17. }
  18. }
  19. int main()
  20. {
  21. int fib0[N];int fib1[N];int fib2[N];
  22. memset(fib0, 0, sizeof(int)*N);
  23. memset(fib1, 0, sizeof(int)*N);
  24. memset(fib2, 0, sizeof(int)*N);
  25. int n;
  26. cin>>n;
  27. fib0[N - 1] = 1;fib1[N - 1] = 1;
  28. ctrl = N - 1;
  29. if(n<2) fib2[N - 1] = 1;
  30. for (int i = 2;i <= n;i++)
  31. {
  32. add(fib0, fib1, fib2);
  33. memmove(fib0, fib1, sizeof(int)*N);
  34. memmove(fib1, fib2, sizeof(int)*N);
  35. }
  36. for(int i = ctrl; i < N; i++) cout<<fib2[i];
  37. return 0;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void add(int*, int*, int*)’:
prog.cpp:8:29: error: ‘memset’ was not declared in this scope
   memset(c, 0, sizeof(int)*N);
                             ^
prog.cpp: In function ‘int main()’:
prog.cpp:22:31: error: ‘memset’ was not declared in this scope
  memset(fib0, 0, sizeof(int)*N);
                               ^
prog.cpp:33:37: error: ‘memmove’ was not declared in this scope
    memmove(fib0, fib1, sizeof(int)*N);
                                     ^
stdout
Standard output is empty