Advertisement
desislava_topuzakova

Untitled

Feb 1st, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Problem08._Greater_of_Two_Values
  4. {
  5. internal class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. string type = Console.ReadLine();
  10.  
  11. if (type.Equals("int"))
  12. {
  13. int a = int.Parse(Console.ReadLine());
  14. int b = int.Parse(Console.ReadLine());
  15. Console.WriteLine( GetMaxInt(a, b));
  16.  
  17. }
  18. if (type.Equals("string"))
  19. {
  20. string a = Console.ReadLine();
  21. string b = Console.ReadLine();
  22. Console.WriteLine(GetMaxString(a, b));
  23. }
  24. if (type.Equals("char"))
  25. {
  26. char a =char.Parse( Console.ReadLine());
  27. char b =char.Parse( Console.ReadLine());
  28. Console.WriteLine(GetMaxChar(a, b));
  29. }
  30.  
  31.  
  32.  
  33. }
  34.  
  35. static int GetMaxInt(int a, int b)
  36. {
  37. if (a > b) {return a;}
  38. else {return b;}
  39. }
  40.  
  41. static string GetMaxString(string a, string b)
  42. {
  43. if (a.Length > b.Length) {return a;}
  44. else {return b;}
  45. }
  46.  
  47. static char GetMaxChar(char a, char b)
  48. {
  49. if ((int) a > (int) b) {return a;}
  50. else{ return b;}
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement