fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int x = 2;
  6.  
  7. int a3 = 1;
  8. int a2 = 2;
  9. int a1 = 3;
  10. int a0 = 4;
  11.  
  12. int t3 = a3 * x * x * x; // x^3
  13. int t2 = a2 * x * x; // 2x^2
  14. int t1 = a1 * x; // 3x
  15. int t0 = a0; // 4
  16.  
  17. int W = t3 + t2 + t1 + t0;
  18.  
  19. cout << "x = " << x << endl;
  20. cout << "a3 * x^3 = " << t3 << endl;
  21. cout << "a2 * x^2 = " << t2 << endl;
  22. cout << "a1 * x = " << t1 << endl;
  23. cout << "a0 = " << t0 << endl;
  24. cout << "W(2) = " << W << endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
x = 2
a3 * x^3 = 8
a2 * x^2 = 8
a1 * x   = 6
a0       = 4
W(2) = 26