Advertisement
Guest User

Untitled

a guest
Mar 14th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int count = int.Parse(Console.ReadLine());
  13.  
  14. int lettersSum = 0;
  15. int SymbolsSum = 0;
  16. int digitsSum = 0;
  17.  
  18. for (int i = 0; i < count; i++)
  19. {
  20. string currentString = Console.ReadLine().ToLower();
  21. // foreach (var ch in currentString) // tozi string moje da se obhodi i s FOREACH
  22. for (int j = 0; j < currentString.Length; j++)
  23. {
  24. char ch = currentString[j];
  25.  
  26. if (ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n')
  27. {
  28. if (ch >= 'a' && ch <= 'z')
  29. {
  30. int weight = ((ch - 'a') + 1) * 10;// vadim chara - a i pribavqme 1 zashtoto a = 97 - c= 99 i se polu4ava 2 a na men mi trqbv ada e 3
  31. lettersSum += weight;
  32. }
  33. else if (ch >= '0' && ch <= '9')
  34. {
  35. int weight = (ch - '0') * 20;
  36. digitsSum += weight;
  37. }
  38. else
  39. {
  40. SymbolsSum += 200;
  41. }
  42. }
  43. }
  44. }
  45. Console.WriteLine(lettersSum);
  46. Console.WriteLine(digitsSum);
  47. Console.WriteLine(SymbolsSum);
  48. }
  49. }
  50. }
  51.  
  52. /* if (ch != ' ' || ch != '\t' || ch != '\r' || ch != '\n')
  53.  
  54. {
  55. lettersSum += 0;
  56. SymbolsSum += 0;
  57. digitsSum += 0;
  58. }
  59. else if (ch >= 'a' && ch <= 'z')
  60. {
  61. int weight = (ch - 'a' + 1) * 10;
  62. lettersSum += weight;
  63. }
  64. else if (ch >= '0' && ch <= '9')
  65. {
  66. int weight = (ch - '0') * 20;
  67. digitsSum += weight;
  68. }
  69. else
  70. {
  71. SymbolsSum += 200;
  72. } */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement