Advertisement
HristoGrigorov

Untitled

Dec 8th, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 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 _07.GreaterOfTwoValues
  8. {
  9. class GreaterOfTwoValues
  10. {
  11. static void Main()
  12. {
  13. string type = Console.ReadLine();
  14.  
  15. if (type == "int")
  16. {
  17. int firstInt = int.Parse(Console.ReadLine());
  18. int secondInt = int.Parse(Console.ReadLine());
  19. Console.WriteLine(PrintGreaterInteger(firstInt, secondInt));
  20. }
  21. else if (type == "char")
  22. {
  23. char firstChar = char.Parse(Console.ReadLine());
  24. char secondChar = char.Parse(Console.ReadLine());
  25. Console.WriteLine(PrintGreaterChar(firstChar, secondChar));
  26.  
  27. }
  28.  
  29. else
  30. {
  31. string firstString = Console.ReadLine();
  32. string secondString = Console.ReadLine();
  33. Console.WriteLine(PringGreaterString(firstString, secondString));
  34. }
  35.  
  36. }
  37.  
  38. static int PrintGreaterInteger(int firstInt, int secondInt)
  39. {
  40. if (firstInt >= secondInt)
  41. {
  42. return firstInt;
  43. }
  44. else
  45. {
  46. return secondInt;
  47. }
  48. }
  49.  
  50. static char PrintGreaterChar(char firstChar, char secondChar)
  51. {
  52. if ((int)firstChar >= (int) secondChar)
  53. {
  54. return firstChar;
  55. }
  56. else
  57. {
  58. return secondChar;
  59. }
  60. }
  61.  
  62. static string PringGreaterString(string firstString, string secondString)
  63. {
  64. if (firstString.Length >= secondString.Length)
  65. {
  66. return firstString;
  67. }
  68. else
  69. {
  70. return secondString;
  71. }
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement