Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. public void calculator_division(int ss, string number1, string number2)
  2. {
  3. cleaning();
  4. Translation tr = new Translation();
  5. if (Convert.ToInt32(number1) >= Convert.ToInt32(number2))
  6. {
  7. tr.translation(ss, number1);
  8. string a_ = tr.Reply;
  9. tr.cleaning();
  10. tr.translation(ss, number2);
  11. string b_ = tr.Reply;
  12. tr.cleaning();
  13. string _b = null;
  14. string c = null;
  15. string ot = null;
  16. string obr = null;
  17. string l = null;
  18. int k = 0;
  19. if (a_.Length > b_.Length)
  20. {
  21. int kol = a_.Length - b_.Length;
  22. while(kol != 0)
  23. {
  24. b_ = b_ + '0';
  25. k++;
  26. kol--;
  27. }
  28. }
  29. int sm = k;
  30. for (int i = 0; i < b_.Length; i++)
  31. {
  32. if (b_[i] == 49)
  33. {
  34. _b = _b + "0";
  35. }
  36. else
  37. {
  38. _b = _b + "1";
  39. }
  40. }
  41. calculator_sum(2, _b, "1");
  42. _b = reply;
  43. if (a_.Length > _b.Length)
  44. {
  45. int kol = a_.Length - _b.Length;
  46. while (kol != 0)
  47. {
  48. _b = '0' + _b ;
  49. kol--;
  50. }
  51. }
  52. calculator_sum(2, a_, _b);
  53. c = reply;
  54. if (c.Length > a_.Length)
  55. {
  56. ot = ot + "1";
  57. c = c.Remove(0, 1);
  58. }
  59. else
  60. {
  61. ot = ot + "0";
  62. }
  63.  
  64. while (k != 0)
  65. {
  66. if(ot[ot.Length - 1] == '0')
  67. {
  68. c = c.Remove(0, 1);
  69. c = c.Insert(c.Length - 1, "0");
  70. calculator_sum(2, c, b_);
  71. }
  72. else
  73. {
  74. c = c.Insert(c.Length - 1, "0");
  75. calculator_sum(2, c, _b);
  76. }
  77. c = reply;
  78. if (c.Length > a_.Length)
  79. {
  80. ot = ot + "1";
  81. c = c.Remove(0, 1);
  82. }
  83. else
  84. {
  85. ot = ot + "0";
  86. }
  87. k--;
  88. }
  89. cleaning();
  90. int g = 0;
  91. while (ot[g] == '0')
  92. {
  93. g++;
  94. }
  95. for (int i = g; i < ot.Length; i++)
  96. {
  97. reply = reply + Convert.ToString(ot[i]);
  98. }
  99. int _0 = 0;
  100. for (int i = 0; i < c.Length; i++)
  101. {
  102. if (c[i] == '0')
  103. {
  104. _0++;
  105. }
  106. }
  107. if (_0 != c.Length)
  108. {
  109. while (sm != 0)
  110. {
  111. int r = c.Length;
  112. c = c.Remove(r - 1);
  113. sm--;
  114. }
  115. g = 0;
  116. while (c[g] == '0')
  117. {
  118. g++;
  119. }
  120. string pr = null;
  121. pr = reply;
  122. for (int i = g; i < c.Length; i++)
  123. {
  124. obr = obr + c[g];
  125. }
  126. if (pr[pr.Length - 1] == '1')
  127. {
  128. //string l = null;
  129. for (int i = 0; i < obr.Length; i++)
  130. {
  131. if (obr[i] == 49)
  132. {
  133. l = l + "0";
  134. }
  135. else
  136. {
  137. l = l + "1";
  138. }
  139. }
  140. calculator_sum(2, l, "1");
  141. obr = reply;
  142. }
  143. cleaning();
  144. reply = pr + "," + obr;
  145. }
  146. Console.WriteLine("{0} ", reply);
  147. }
  148. else
  149. {
  150. reply = "0";
  151. }
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement