Advertisement
Guest User

Untitled

a guest
May 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int a,b,c;
  6. bool s = 1;
  7. cin >> a >> b >> c;
  8. if (a != 0)
  9. {
  10. cout << a;
  11. s = 0;
  12. }
  13. if (b != 0)
  14. {
  15. if (b == 1)
  16. {
  17. if (a == 0)
  18. cout << "x";
  19. else
  20. cout << "+x";
  21. }
  22. else if (b == -1)
  23. cout << "-x";
  24. else if ((b < 0) or (a == 0))
  25. cout << b << "x";
  26. else
  27. cout << "+" << b << "x";
  28. s = 0;
  29. }
  30. if (c != 0)
  31. {
  32. if (c == 1)
  33. {
  34. if ((a == 0) and (b == 0))
  35. cout << "y";
  36. else
  37. cout << "+x";
  38. }
  39. else if (c == -1)
  40. cout << "-y";
  41. else if ((c < 0) or ((a == 0) and (b == 0)))
  42. cout << c << "y";
  43. else
  44. cout << "+" << c << "y";
  45. s = 0;
  46. }
  47. if (s)
  48. cout << 0;
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement