Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main()
  5. {
  6. string line;
  7. char a;
  8. bool rl=false;
  9. int s1, s2, z1 = 0, z2 = 0, size;
  10. __int64 f1 = 0, f2 = 0;
  11. while (getline(cin, line))
  12. {
  13. rl = false;
  14. s1 = 0; s2 = 0;
  15. z1 = 0; z2 = 0;
  16. f1 = 0; f2 = 0;
  17. size = line.size();
  18. for (int i = 0; i < size; i++)
  19. {
  20. if (line[i] == '^')
  21. z1 = i;
  22. }
  23. for (int i = 0; i < size; i++)
  24. {
  25. if (line[i] == '=')
  26. {
  27. if (rl == false)
  28. z1--;
  29. else
  30. z2++;
  31. }
  32. else if (line[i] == '^')
  33. rl = true;
  34. else
  35. {
  36. if (rl == false)
  37. {
  38. s1 = line[i] - 48;
  39. f1 = f1 + s1*z1;
  40. z1--;
  41. }
  42.  
  43. else
  44. {
  45. z2++;
  46. s2 = line[i] - 48;
  47. f2 = f2 + s2*z2;
  48. }
  49.  
  50.  
  51. }
  52.  
  53. }
  54. if (z1 == 0)
  55. z1 = 1;
  56. if (z2 == 0)
  57. z2 = 1;
  58. if (f1 > f2)
  59. cout << "left" << endl;
  60. if (f1 < f2 )
  61. cout << "right" << endl;
  62. if (f1 == f2 )
  63. cout << "balance" << endl;
  64.  
  65. }
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement