Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace CharacterMultiplier
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- string[] words = Console.ReadLine().Split();
- int sum=ReturnSum(words);
- Console.WriteLine(sum);
- }
- private static int ReturnSum(string[] words)
- {
- string shorterString = string.Empty;
- string longerString = string.Empty;
- int sum = 0;
- int minLength = Math.Min(words[0].Length, words[1].Length);
- if (minLength == words[0].Length)
- {
- shorterString = words[0];
- longerString = words[1];
- }
- else
- {
- shorterString = words[1];
- longerString = words[0];
- }
- for (int i = 0; i < shorterString.Length; i++)
- {
- sum += shorterString[i] * longerString[i];
- }
- for (int i = shorterString.Length; i < longerString.Length; i++)
- {
- sum += longerString[i];
- }
- return sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement