Advertisement
Stan0033

Untitled

Jul 26th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace apps
  5. {
  6. class Program
  7. {
  8.  
  9. static int GetInt() { return int.Parse(Console.ReadLine()); }
  10. static string Get() { return Console.ReadLine(); }
  11.  
  12. static void Main()
  13. {
  14. // character multiplier
  15. string[] inp = Get().Split(' ').ToArray();
  16. //------------------------------------------------------------
  17. //------------------------------------------------------------
  18. List<int> codes1 = new List<int>();
  19. List<int> codes2 = new List<int>();
  20. //------------------------------------------------------------
  21. //------------------------------------------------------------
  22. foreach (char c in inp[0]) { int code = (int)c; codes1.Add(code); }
  23. foreach (char c in inp[1]) { int code = (int)c; codes2.Add(code); }
  24. //------------------------------------------------------------
  25. //------------------------------------------------------------
  26. int empty = 0;
  27. int total = 0;
  28. //------------------------------------------------------------
  29. //------------------------------------------------------------
  30. while (true)
  31. {
  32. if (codes1.Count == 0 && codes2.Count==0) { break; }
  33. if (codes1.Count == 0) {empty = 1; break;}
  34. if (codes2.Count == 0) { empty = 2; break; }
  35. int sum= (codes1[0] * codes2[0]);
  36. total += sum;
  37. codes1.RemoveAt(0);
  38. codes2.RemoveAt(0);
  39. }
  40. //------------------------------------------------------------
  41. //------------------------------------------------------------
  42. if (empty == 1) { foreach (int value in codes2) { total += value; } }
  43. if (empty == 2) { foreach (int value in codes1) { total += value; } }
  44. //------------------------------------------------------------
  45. //------------------------------------------------------------
  46.  
  47. Console.WriteLine(total);
  48.  
  49. }
  50.  
  51. }// END MAIN
  52.  
  53. }
  54.  
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement