Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. namespace _04.CharacterMultiplier
  2. {
  3. using System;
  4.  
  5. public class StartUp
  6. {
  7. public static void Main()
  8. {
  9. var input = Console.ReadLine().Split();
  10. char[] arrOne = input[0].ToCharArray();
  11. char[] arrTwo = input[1].ToCharArray();
  12.  
  13. int shortes = Math.Min(arrOne.Length, arrTwo.Length);
  14. int sum = 0;
  15. for (int i = 0; i < shortes; i++)
  16. {
  17. sum += arrOne[i] * arrTwo[i];
  18. }
  19. int longest = Math.Max(arrOne.Length, arrTwo.Length);
  20. char[] finaeElements = longest == arrOne.Length ? arrOne : arrTwo;
  21. for (int i = longest-1; i >= shortes; i--)
  22. {
  23. sum += finaeElements[i];
  24. }
  25. Console.WriteLine(sum);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement