Advertisement
Guest User

Name Wars

a guest
Oct 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 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 Odd_Even_Position
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. string name = Console.ReadLine(); //vuvejdame imeto
  15. int sum = 0;
  16. int nameMax = 0;
  17. string winner = "";
  18.  
  19.  
  20.  
  21. while (name != "STOP")
  22. {
  23. for (int i = 0; i < name.Length; i++) //minavame prez vsqka bukva
  24. {
  25. char letter = name[i];
  26. sum += (int)letter;
  27.  
  28.  
  29. }
  30. if (sum > nameMax)
  31. {
  32. nameMax = sum;
  33. winner = name;
  34. }
  35. sum = 0;
  36. name = Console.ReadLine();
  37. }
  38.  
  39. Console.WriteLine($"Winner is {winner} - {nameMax}!");
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement