Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. Public static Summer (Stack <int> S1, Stack <int> S2)
  2. {
  3. int count, sum1 = 0; sum2 = 0, a,b,c,d;
  4. bool flag;
  5. Stack <int> temp = new Stack <int>();'
  6.  
  7. While (S1.IsEmpty() && flag == true)
  8.     {
  9.         flag = true;
  10.         a = S1.Pop();
  11.         b = S1.Top();'
  12.         sum1 = a + b;
  13.  
  14.         While (!S2.IsEmpty())
  15.         {
  16.             c = S2.Pop();
  17.             d = s2.Top();
  18.             sum2 = c+d;
  19.             if ( sum2 > sum1)
  20.                 flag = false;
  21.             temp.Push(C);
  22.             }
  23.             While (!temp.IsEmpty())
  24.                 S2.Push(temp.Pop());
  25.  
  26.             if (flag)
  27.                  return sum1;
  28.         }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement