MayaIP

Untitled

Jun 6th, 2017
475
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace GreaterOfTwoValues
  8. {
  9. class GreaterOfTwoValues
  10. {
  11. static void Main(string[] args)
  12. {
  13. string valueType = Console.ReadLine().ToLower();
  14.  
  15. if (valueType == "int")
  16. {
  17. int value1 = int.Parse(Console.ReadLine());
  18. int value2 = int.Parse(Console.ReadLine());
  19.  
  20. int maxInt = getMaxInt(value1, value2);
  21. Console.WriteLine(maxInt);
  22. }
  23. else if (valueType == "char")
  24. {
  25. char ch1 = char.Parse(Console.ReadLine());
  26. char ch2 = char.Parse(Console.ReadLine());
  27.  
  28. char maxChar = getMaxChar(ch1, ch2);
  29. Console.WriteLine(maxChar);
  30. }
  31. else if (valueType == "string")
  32. {
  33. string str1 = Console.ReadLine();
  34. string str2 = Console.ReadLine();
  35.  
  36. string maxStr = getMaxStr(str1, str2);
  37. Console.WriteLine(maxStr);
  38. }
  39. }
  40.  
  41. static int getMaxInt(int value1, int value2)
  42. {
  43. if (value1 > value2)
  44. {
  45. return value1;
  46. }
  47. else
  48. {
  49. return value2;
  50. }
  51. }
  52.  
  53. static char getMaxChar(char ch1, char ch2)
  54. {
  55. if (ch1 > ch2)
  56. {
  57. return ch1;
  58. }
  59. else
  60. {
  61. return ch2;
  62. }
  63. }
  64.  
  65. static string getMaxStr(string str1, string str2)
  66. {
  67. if (str1.CompareTo(str2)>=0)
  68. {
  69. return str1;
  70. }
  71. else
  72. {
  73. return str2;
  74. }
  75. }
  76. }
  77. }
RAW Paste Data