fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a, b;
  7. cin >> a >> b;
  8. cout << "f(x)=";
  9. if (a == -1) {
  10. cout << "-x";
  11. } else if (a == 1) {
  12. cout << "x";
  13. } else if (a != 0) {
  14. cout << a << "x";
  15. }
  16. if (b > 0) {
  17. if (a != 0) {
  18. cout << "+";
  19. }
  20. cout << b;
  21. } else if (b < 0) {
  22. cout << b;
  23. }
  24. if (a == 0 && b == 0) {
  25. cout << 0;
  26. }
  27. cout << endl;
  28. return 0;
  29. }
Success #stdin #stdout 0s 4480KB
stdin
2 -3
stdout
f(x)=2x-3