Advertisement
Guest User

Untitled

a guest
Jun 16th, 2018
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CharacterMultiplier
  4. {
  5.     class CharacterMultiplier
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string[] input = Console.ReadLine().Split();
  10.  
  11.             char[] char1 = input[0].ToCharArray();
  12.             char[] char2 = input[1].ToCharArray();
  13.  
  14.             int totalSum = 0;
  15.             for (int i = 0; i < Math.Max(char1.Length, char2.Length); i++)
  16.             {
  17.                 if (i < char1.Length && i < char2.Length)
  18.                 {
  19.                     totalSum += char1[i] * char2[i];
  20.                 }
  21.                 else if (i < char1.Length && i >= char2.Length)
  22.                 {
  23.                     totalSum += char1[i];
  24.                 }
  25.                 else if (i >= char1.Length && i < char2.Length)
  26.                 {
  27.                     totalSum += char2[i];
  28.                 }
  29.             }
  30.             Console.WriteLine(totalSum);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement