Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace FromLefttoTheRight
- {
- class Program
- {
- static void Main(string[] args)
- {
- int count = int.Parse(Console.ReadLine());
- string currentNum;
- string leftNum = string.Empty;
- string rightNum = string.Empty;
- int space = 0;
- int minus = 0;
- int leftSum = 0;
- int rightSum = 0;
- int symbolAsInteger;
- for (int i = 0; i < count; i++)
- {
- currentNum = Console.ReadLine();
- for (int index = 0; index < currentNum.Length; index++)
- {
- char symbol = currentNum[index];
- string symbolAsString = symbol.ToString();
- while (true)
- {
- if (symbol == ' ')
- {
- space++;
- break;
- }
- else if (symbol == '-')
- {
- minus++;
- break;
- }
- if (space == 0 && minus == 1 || space == 0 && minus == 0)
- {
- leftNum += symbol;
- symbolAsInteger = int.Parse(symbolAsString);
- leftSum += symbolAsInteger;
- break;
- }
- else
- {
- rightNum += symbol;
- symbolAsInteger = int.Parse(symbolAsString);
- rightSum += symbolAsInteger;
- break;
- }
- }
- }
- if (leftSum > rightSum)
- Console.WriteLine(leftSum);
- else
- Console.WriteLine(rightSum);
- space = 0;
- minus = 0;
- leftSum = 0;
- rightSum = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement