TeMePyT

Untitled

May 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08.Greater_of_Two_Values
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string type = Console.ReadLine();
  14. if(type=="int")
  15. {
  16. int num1 = int.Parse(Console.ReadLine());
  17. int num2 = int.Parse(Console.ReadLine());
  18. Console.WriteLine(GetMax(num1, num2));
  19. }
  20. else if(type=="char")
  21. {
  22. char ch1 = Convert.ToChar(Console.ReadLine());
  23. char ch2 = Convert.ToChar(Console.ReadLine());
  24. Console.WriteLine(GetMax(ch1, ch2));
  25. }
  26. else if (type=="string")
  27. {
  28. string str1 = Console.ReadLine();
  29. string str2 = Console.ReadLine();
  30. Console.WriteLine(GetMax(str1, str2));
  31. }
  32. }
  33. static int GetMax(int num1, int num2)
  34. {
  35. if (num1 >= num2)
  36. {
  37. return num1;
  38. }
  39. else
  40. {
  41. return num2;
  42. }
  43. }
  44. static char GetMax(char ch1, char ch2)
  45. {
  46. if (ch1 >= ch2)
  47. {
  48. return ch1;
  49. }
  50. else
  51. {
  52. return ch2;
  53. }
  54. }
  55. static string GetMax(string str1, string str2)
  56. {
  57. if (str1.CompareTo(str2) >= 0)
  58. {
  59. return str1;
  60. }
  61. else
  62. {
  63. return str2;
  64. }
  65. }
  66. }
  67. }
Add Comment
Please, Sign In to add comment