Advertisement
Kolimnared

MultiplicationSign

Oct 17th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. class MultiplicationSign
  4. {
  5. private static int GetInt(string intName)
  6. {
  7. while (true)
  8. {
  9. Console.Write("Enter " + intName + ": ");
  10. string str = Console.ReadLine();
  11. int i;
  12. bool isSuccessful = int.TryParse(str, out i);
  13. if (isSuccessful)
  14. return i;
  15. }
  16. }
  17.  
  18. static void Main(string[] args)
  19. {
  20. int a = GetInt("a");
  21. int b = GetInt("b");
  22. int c = GetInt("c");
  23.  
  24. if ( (a & (b & c)) == 0) {
  25. Console.WriteLine("0");
  26. }
  27. else if (((a ^ (b ^ c)) < 0) ||
  28. ((b ^ (a ^ c)) < 0) ||
  29. ((c ^ (a ^ b)) < 0)) {
  30. Console.WriteLine("-");
  31. }
  32. else {
  33. Console.WriteLine("+");
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement