Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02._From_Left_to_The_Right
- {
- class Program
- {
- static void Main(string[] args)
- {
- int countLines = int.Parse(Console.ReadLine());
- int leftSum = 0;
- int rightSum = 0;
- for (int i = 1; i <= countLines; i++)
- {
- string number = Console.ReadLine();
- for (int j = 0; j < number.Length; j++)
- {
- char symbol = number[j];
- if ((int)symbol != 32)
- {
- leftSum += symbol- '0';
- }
- else
- {
- break;
- }
- }
- for (int k = number.Length-1; k>=0 ; k--)
- {
- char symbol = number[k];
- if ((int)symbol != 32)
- {
- rightSum += symbol - (int)'0';
- }
- else
- {
- break;
- }
- }
- if (rightSum> leftSum)
- {
- Console.WriteLine(rightSum);
- }
- else
- {
- Console.WriteLine(leftSum);
- }
- rightSum = 0;
- leftSum = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment