Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace apps
- {
- class Program
- {
- static int GetInt() { return int.Parse(Console.ReadLine()); }
- static string Get() { return Console.ReadLine(); }
- static void Main()
- {
- // character multiplier
- string[] inp = Get().Split(' ').ToArray();
- //------------------------------------------------------------
- //------------------------------------------------------------
- List<int> codes1 = new List<int>();
- List<int> codes2 = new List<int>();
- //------------------------------------------------------------
- //------------------------------------------------------------
- foreach (char c in inp[0]) { int code = (int)c; codes1.Add(code); }
- foreach (char c in inp[1]) { int code = (int)c; codes2.Add(code); }
- //------------------------------------------------------------
- //------------------------------------------------------------
- int empty = 0;
- int total = 0;
- //------------------------------------------------------------
- //------------------------------------------------------------
- while (true)
- {
- if (codes1.Count == 0 && codes2.Count==0) { break; }
- if (codes1.Count == 0) {empty = 1; break;}
- if (codes2.Count == 0) { empty = 2; break; }
- int sum= (codes1[0] * codes2[0]);
- total += sum;
- codes1.RemoveAt(0);
- codes2.RemoveAt(0);
- }
- //------------------------------------------------------------
- //------------------------------------------------------------
- if (empty == 1) { foreach (int value in codes2) { total += value; } }
- if (empty == 2) { foreach (int value in codes1) { total += value; } }
- //------------------------------------------------------------
- //------------------------------------------------------------
- Console.WriteLine(total);
- }
- }// END MAIN
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement