fork download
  1. #include <iostream>
  2.  
  3. static const int SIZE = 5;
  4.  
  5. bool have_next() {
  6. static int counter{};
  7.  
  8. return (SIZE > counter++);
  9. }
  10.  
  11. int next_koeff() {
  12. static int counter{};
  13. static int koefs[SIZE]{23,11,4,9,17};
  14.  
  15. return koefs[counter++];
  16. }
  17.  
  18. int main() {
  19.  
  20. int polinom_sum{};
  21. int x{};
  22.  
  23. std::cin >> x;
  24.  
  25. while (have_next()) {
  26. polinom_sum *= x;
  27. polinom_sum += next_koeff();
  28. }
  29.  
  30. std::cout << polinom_sum;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 3300KB
stdin
2
stdout
507