Advertisement
Guest User

07. Greater of Two Values

a guest
Oct 2nd, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CryptoCS
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. string value = Console.ReadLine();
  10.  
  11. if (value == "int")
  12. {
  13. int a = int.Parse(Console.ReadLine());
  14. int b = int.Parse(Console.ReadLine());
  15. Console.WriteLine(Math.Max(a, b));
  16. }
  17. else if (value == "char")
  18. {
  19. char c = char.Parse(Console.ReadLine());
  20. char d = char.Parse(Console.ReadLine());
  21. Console.WriteLine(Convert.ToChar(Math.Max(c, d)));
  22. }
  23. else if (value == "string")
  24. {
  25. string g = Console.ReadLine();
  26. string h = Console.ReadLine();
  27. int gNumber = 0;
  28. int hNumber = 0;
  29.  
  30. foreach (char c in g)
  31. {
  32. gNumber += c;
  33. }
  34. foreach (char c in h)
  35. {
  36. hNumber += c;
  37. }
  38. if (gNumber > hNumber)
  39. {
  40. Console.WriteLine(g);
  41. }
  42. else
  43. {
  44. Console.WriteLine(h);
  45. }
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement