Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 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 _1st_exs
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. /**
  14. string character = "duma";
  15. //int value = (int) character;
  16. //Console.WriteLine(value);
  17.  
  18. char[] split = character.ToCharArray();
  19.  
  20. foreach(char letter in split)
  21. {
  22. Console.WriteLine(letter);
  23. }
  24. */
  25.  
  26. bool condition = true;
  27. int maxValue = 0;
  28. string maxValueWord = "";
  29. while (condition)
  30. {
  31. int sum = 0;
  32. string input = Console.ReadLine();
  33.  
  34. //Leaving the loop
  35. if (input == "END OF GAME")
  36. {
  37. condition = false;
  38. break;
  39. }
  40.  
  41. //Splitting the word into chars
  42. char[] split = input.ToCharArray();
  43.  
  44. //Looping threw the whole word
  45. foreach (char letter in split)
  46. {
  47. int value = (int)letter;
  48.  
  49. //Big Letter
  50. if (value >= 65 && value <= 90)
  51. {
  52. sum += 15;
  53. }
  54. sum += value;
  55. }
  56.  
  57. //Checking if last element is "t" (116)
  58. if ((int)split[split.Length - 1] == 116)
  59. {
  60. sum += 20;
  61. }
  62.  
  63. //Checking for biggest value and word
  64. if (sum > maxValue)
  65. {
  66. maxValue = sum;
  67. maxValueWord = input;
  68. }
  69. else
  70. {
  71. sum = 0;
  72. }
  73.  
  74. }
  75. Console.WriteLine("Winner is word: {0}", maxValueWord);
  76. Console.WriteLine("Points: {0}", maxValue);
  77.  
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement