Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. namespace IzpitCsharp2
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. class IzpitCsharp2
  9. {
  10. static void Main()
  11. {
  12. //grrrr miao miao
  13. string input = Console.ReadLine();
  14.  
  15. List<string> catInput = input.Split(' ').ToList();
  16. var catCode = new List<string> { "a", "b", "c", "d", "e", "f", "g", "h", "i",
  17. "j", "k", "l", "m", "n", "o", "p", "q", "r", "s" };
  18.  
  19. List<int> catNumber = new List<int>();
  20. string currentWord = string.Empty;
  21. int currentSum = 0;
  22. int sum = 0;
  23.  
  24. for (int i = 0; i < catInput.Count; i++)
  25. {
  26. currentWord = catInput[i];
  27. currentSum = 0;
  28.  
  29. for (int j = 0; j < currentWord.Length; j++)
  30. {
  31. if (catCode.Contains(currentWord[j].ToString()))
  32. {
  33. catNumber.Add(catCode.IndexOf(currentWord[j].ToString()));
  34. }
  35. }
  36.  
  37. for (int n = 0; n < catNumber.Count; n++)
  38. {
  39. int digits = int.Parse((catNumber[n].ToString()));
  40. currentSum += digits * powerOfNine(catNumber.Count - n - 1);
  41. sum += currentSum;
  42. }
  43. }
  44.  
  45.  
  46. Console.WriteLine(sum);
  47. }
  48. static int powerOfNine(int power)
  49. {
  50. int result = 1;
  51.  
  52. for (int i = 0; i < power; i++)
  53. {
  54. result *= 19;
  55. }
  56. return result;
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement