Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class CharachterMultiplier
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine()
- .Split()
- .ToArray();
- string firstText = input[0];
- string secondText = input[1];
- int result = Multiply(firstText, secondText);
- Console.WriteLine(result);
- }
- static int Multiply(string firstText, string secondText)
- {
- int minLength = Math.Min(firstText.Length, secondText.Length);
- int maxLength = Math.Max(firstText.Length, secondText.Length);
- int result = 0;
- for (int index = 0; index < minLength; index++)
- {
- result += firstText[index] * secondText[index];
- }
- for (int index = minLength; index < maxLength; index++)
- {
- if (firstText.Length > secondText.Length)
- {
- result += firstText[index];
- }
- else
- {
- result += secondText[index];
- }
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment