Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace 02. Character Multiplier
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] word = Console.ReadLine().Split().ToArray();
- string firstWord = word[1];
- string secondWord = word[0];
- if (word[0].Length >= word[1].Length)
- {
- firstWord = word[0];
- secondWord = word[1];
- }
- int minWordLenght = Math.Min(word[0].Length, word[1].Length);
- int maxWordLenght = Math.Max(word[0].Length, word[1].Length);
- int sum = 0;
- for (int i = 0; i < minWordLenght; i++)
- {
- char firstLetter = firstWord[i];
- char secondLetter = secondWord[i];
- sum += firstLetter * secondLetter;
- }
- for (int i = minWordLenght; i < maxWordLenght; i++)
- {
- char firstLetter = firstWord[i];
- sum += firstLetter;
- }
- Console.WriteLine(sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement