Advertisement
rosenrusev

Problem 1 - Exchange If Greater

Mar 19th, 2014
1,735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ExchangeIfGreater
  4. {
  5. class ExchangeIfGreater
  6. {
  7. static void Main()
  8. {
  9. int a = int.Parse(Console.ReadLine());
  10. int b = int.Parse(Console.ReadLine());
  11.  
  12. if (a > b)
  13. { // XOR algorithm
  14. a = a ^ b;
  15. b = a ^ b;
  16. a = a ^ b;
  17. Console.WriteLine(a + " " + b);
  18. }
  19. else
  20. {
  21. Console.WriteLine(a + " " + b);
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement