Advertisement
Dimo1985

Untitled

Jan 27th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4.  
  5. namespace ConsoleApp18
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int numbers = int.Parse(Console.ReadLine());
  12.            
  13.            
  14.             for (int i = 0; i < numbers; i++)
  15.             {
  16.                 int sum = 0;
  17.                 double numMax = 0;
  18.                 double[] arr = Console.ReadLine().Split(" ").Select(double.Parse).ToArray();
  19.                 double numLeft = arr[0];
  20.                 double numRight = arr[1];
  21.                 numMax = numLeft;
  22.                 if (numLeft < numRight)
  23.                 {
  24.                     numMax = numRight;
  25.                 }
  26.                 string maxNumberAbs = Math.Abs(numMax).ToString();
  27.                 for (int x = 0; x < maxNumberAbs.Length; x++)
  28.                 {
  29.                     char digit = maxNumberAbs[x];
  30.                     sum = sum + int.Parse(digit.ToString());
  31.                 }
  32.                 Console.WriteLine(sum);
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement