Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int count = int.Parse(Console.ReadLine());
- int lettersSum = 0;
- int SymbolsSum = 0;
- int digitsSum = 0;
- for (int i = 0; i < count; i++)
- {
- string currentString = Console.ReadLine().ToLower();
- // foreach (var ch in currentString) // tozi string moje da se obhodi i s FOREACH
- for (int j = 0; j < currentString.Length; j++)
- {
- char ch = currentString[j];
- if (ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n')// ako ch e razli4no ot tezi simvoli to da vliza v if i da izvurshva tezi operacii
- {
- if (ch >= 'a' && ch <= 'z')
- {
- int weight = ((ch - 'a') + 1) * 10;// vadim chara - a i pribavqme 1 zashtoto a = 97 - c= 99 i s epolu4ava 2 a na men mi trqbva da e 3
- lettersSum += weight;
- }
- else if (ch >= '0' && ch <= '9')
- {
- int weight = (ch - '0') * 20;// na 0 ne e nujno da pribavqme 1 zashtoto kakto z 'a'- bukvite zashtoto 0 = 48 - 50 = 2 razlikata mi e 2 kolkoto i trqbva da e chisloto
- digitsSum += weight;
- }
- else
- {
- SymbolsSum += 200;
- }
- }
- }
- }
- Console.WriteLine(lettersSum);
- Console.WriteLine(digitsSum);
- Console.WriteLine(SymbolsSum);
- }
- }
- }
- ////// vtori variant za if else ///////////////
- /* if ((ch >= 'a' && ch <= 'z') && (ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n'))
- {
- int weight = ((ch - 'a') + 1) * 10;
- lettersSum += weight;
- }
- else if ((ch >= '0' && ch <= '9') && (ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n'))
- {
- int weight = (ch - '0') * 20;
- digitsSum += weight;
- }
- else if (ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n')
- {
- SymbolsSum += 200;
- } */
- ///////////////////// taka go e napravil a4kata po-chisto e
- int curChar = input[j];
- if (curChar >= 'A' && input[j] <= 'Z')
- {
- curChar = (input[j] - 64) * 10;
- sumLetters += curChar;
- }
- else if (input[j] >= '0' && input[j] <= '9')
- {
- curChar = (input[j] - 48) * 20;
- sumNumbers += curChar;
- ///////////////////////////////// 2 reshenie na a4kata //////////////////////////////////
- int n = int.Parse(Console.ReadLine());
- int sumLetters = 0;
- int sumNumbers = 0;
- int sumSymbols = 0;
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine().ToUpper();
- input = Regex.Replace(input, "\\s+", "");
- for (int j = 0; j < input.Length; j++)
- {
- int curChar = input[j];
- if (curChar >= 'A' && input[j] <= 'Z')
- {
- curChar = (input[j] - 64) * 10;
- sumLetters += curChar;
- }
- else if (input[j] >= '0' && input[j] <= '9')
- {
- curChar = (input[j] - 48) * 20;
- sumNumbers += curChar;
- }
- else
- {
- sumSymbols += 200;
- }
- }
- }
- Console.WriteLine(sumLetters);
- Console.WriteLine(sumNumbers);
- Console.WriteLine(sumSymbols);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement