Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- namespace Task2
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(' ').ToArray();
- string str1 = input[0];
- string str2 = input[1];
- int Sum = 0;
- if (str1.Length < str2.Length)
- {
- for (int i = 0; i < str1.Length; i++)
- {
- int str1Value = str1[i];
- int str2Value = str2[i];
- Sum += str1Value * str2Value;
- if (i == str1.Length - 1)
- {
- string difference = str2.Substring(str1.Length);
- int differenceValue = str2.IndexOf(difference);
- Sum += differenceValue;
- }
- }
- }
- if (str1.Length > str2.Length)
- {
- int str1Value = 0;
- int str2Value = 0;
- for (int i = 0; i < str2.Length; i++)
- {
- str1Value = str1[i];
- str2Value = str2[i];
- Sum += str1Value * str2Value;
- if (i == str2.Length - 1)
- {
- string difference = str1.Substring(str2.Length);
- int differenceValue = str1.IndexOf(difference);
- Sum += differenceValue;
- }
- }
- }
- if(str1.Length == str2.Length)
- {
- for (int i = 0; i < str2.Length; i++)
- {
- int str1Value = str1[i];
- int str2Value = str2[i];
- Sum += str1Value * str2Value;
- }
- }
- Console.WriteLine(Sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement