Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 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 DomashniPractice
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. int n = int.Parse(Console.ReadLine());
  15. int character;
  16. int numbers = 0;
  17. int bigletters = 0;
  18. int smallLetters = 0;
  19. int otherSymbols = 0;
  20.  
  21. string numbers1 = "";
  22. string bigletters1 = "";
  23. string smallLetters1 = "";
  24. string otherSymbols1 = "";
  25.  
  26.  
  27.  
  28. for (int i = 0; i < n; i++)
  29. {
  30.  
  31. character = Char.Parse(Console.ReadLine());
  32.  
  33. if ((int)character >= 48 && (int)character <= 57)
  34. {
  35. numbers += character;
  36. numbers1 += (char)character;
  37.  
  38. }
  39. else if ((int)character >= 65 && (int)character <= 90)
  40. {
  41. bigletters += character;
  42. bigletters1 += (char)character;
  43.  
  44. }
  45. else if ((int)character >= 97 && (int)character <= 122)
  46. {
  47. smallLetters += character;
  48. smallLetters1 += (char)character;
  49.  
  50. }
  51. else
  52. {
  53. otherSymbols += character;
  54. otherSymbols1 += (char)character;
  55.  
  56.  
  57. }
  58. }
  59.  
  60. if ((numbers != 0 && numbers == bigletters) || (numbers != 0 && numbers == smallLetters) || (numbers != 0 && numbers == otherSymbols))
  61. {
  62. Console.WriteLine("Biggest ASCII sum is:" + numbers);
  63. Console.WriteLine("Combination of characters is:" + numbers1);
  64.  
  65. }
  66. else if ((bigletters != 0 && bigletters == smallLetters) || (bigletters != 0 && bigletters == otherSymbols))
  67. {
  68. Console.WriteLine("Biggest ASCII sum is:" + bigletters);
  69. Console.WriteLine("Combination of characters is:" + bigletters1);
  70.  
  71. }
  72. else if (smallLetters != 0 && smallLetters == otherSymbols)
  73. {
  74. Console.WriteLine("Biggest ASCII sum is:" + smallLetters);
  75. Console.WriteLine("Combination of characters is:" + smallLetters1);
  76.  
  77. }
  78.  
  79. else
  80. {
  81. Console.WriteLine("Biggest ASCII sum is:" + Math.Max(Math.Max(Math.Max((int)numbers, (int)bigletters), (int)smallLetters), (int)otherSymbols));
  82.  
  83. if(Math.Max(Math.Max(Math.Max((int)numbers, (int)bigletters), (int)smallLetters), (int)otherSymbols) == numbers)
  84. {
  85. Console.WriteLine("Combination of characters is:" + numbers1);
  86. }
  87. else if (Math.Max(Math.Max(Math.Max((int)numbers, (int)bigletters), (int)smallLetters), (int)otherSymbols) == bigletters)
  88. {
  89. Console.WriteLine("Combination of characters is:" + bigletters1);
  90. }
  91. else if (Math.Max(Math.Max(Math.Max((int)numbers, (int)bigletters), (int)smallLetters), (int)otherSymbols) == smallLetters)
  92. {
  93. Console.WriteLine("Combination of characters is:" + smallLetters1);
  94. }
  95. else
  96. {
  97. Console.WriteLine("Combination of characters is:" + otherSymbols1);
  98.  
  99. }
  100. }
  101.  
  102.  
  103.  
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement