Bu yerda C++ dasturining misollaridan biri top-down va bottom-up fokus bilan dinamik dasturlashdan foydalanib Fibonacci ketma-ketligining o'ninchi sonini hisoblash uchun quyidagicha: Top-Down: #include <iostream> #include <vector> using namespace std; vector<int> memo(100, -1); int fib(int n) { if (memo[n]!= -1) { return memo[n]; } if (n <= 1) { memo[n] = n; } else { memo[n] = fib-1) + fib(n-2); } return memo[n]; } main {) n; cout << "Ing n sonini n "; >> n; cout << " << n " Fibonacci sonini n: " fib " end " << n "; << endn "; return memo = 0; bottom-up:
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence