|
|
back to boardМоё решение/My Solution C# Posted by Toriki 16 Oct 2017 23:12 using System; namespace SMSSpam { class Program { static void Main(string[] args) { string spam = Console.ReadLine(); Console.WriteLine(spamPrice(spam.ToLower())); Console.ReadKey(); } static int spamPrice (string spam) { int price = 0; foreach (char letter in spam) { price += LetterPrice(letter); } return price; } static int LetterPrice (char letter) { string charSet = "abcdefghijklmnopqrstuvwxyz*.,! "; return (charSet.IndexOf(letter) % 3) + 1; } } } |
|
|