Advertisement
GabrielDas

Untitled

Feb 2nd, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace FromLeftToTheRight
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14.  
  15. for (int i = 0; i < n; i++)
  16. {
  17. string input = Console.ReadLine();
  18.  
  19. if (input.Contains(" "))
  20. {
  21. int index = input.IndexOf(" ");
  22. Int64 firstSum = 0;
  23. Int64 secondSum = 0;
  24. Int64 tempForFirstNum = 0;
  25. Int64 tempForSecondNum = 0;
  26.  
  27. string firstLoweredString = input.Remove(index);
  28. Int64 firstLoweredStringIntoNum = Int64.Parse(firstLoweredString);
  29. tempForFirstNum = Math.Abs(firstLoweredStringIntoNum);
  30.  
  31. string secondLoweredString = input.Remove(0, (firstLoweredString.Length + 1));
  32. Int64 secondLoweredStringIntoNum = Int64.Parse(secondLoweredString);
  33. tempForSecondNum = Math.Abs(secondLoweredStringIntoNum);
  34.  
  35.  
  36. if (firstLoweredStringIntoNum > secondLoweredStringIntoNum)
  37. {
  38. do
  39. {
  40.  
  41. Int64 lastDigit = tempForFirstNum % 10;
  42. firstSum += lastDigit;
  43. tempForFirstNum /= 10;
  44.  
  45. } while (tempForFirstNum > 0);
  46.  
  47.  
  48. Console.WriteLine(firstSum);
  49. }
  50. else
  51. {
  52. do
  53. {
  54. Int64 lastDigit = tempForSecondNum % 10;
  55. secondSum += lastDigit;
  56. tempForSecondNum /= 10;
  57.  
  58. } while (tempForSecondNum > 0);
  59. Console.WriteLine(secondSum);
  60. }
  61.  
  62.  
  63. }
  64. }
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement