Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
2,029
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. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         string[] input = Console.ReadLine().Split();
  8.  
  9.         string str1 = input[0];
  10.         string str2 = input[1];
  11.  
  12.         int minLen = Math.Min(str1.Length, str2.Length);
  13.         int maxLen = Math.Max(str1.Length, str2.Length);
  14.         int sum = 0;
  15.  
  16.         for (int i = 0; i < minLen; i++)
  17.         {
  18.             sum += MultiplyCharsASCII(str1[i], str2[i]);
  19.         }                    
  20.  
  21.         if (str1.Length != str2.Length)
  22.         {
  23.             string longerInput = str1.Length > str2.Length ? longerInput = str1 : longerInput = str2;
  24.             for (int i = minLen; i < maxLen; i++)
  25.             {
  26.                 sum += longerInput[i];
  27.             }
  28.         }
  29.         Console.WriteLine(sum);
  30.     }  
  31.  
  32.     static int MultiplyCharsASCII(char let1, char let2)
  33.     {            
  34.         int multiply = let1*let2;
  35.         return multiply;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement