Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 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 ConsoleApp35
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.            
  13.         {
  14.  
  15.             double biggest = double.MinValue;
  16.             double sum = 0;
  17.             int round = int.Parse(Console.ReadLine());
  18.             for (int i = 0; i<round; i++)
  19.             {
  20.                 double number = double.Parse(Console.ReadLine());
  21.                
  22.                 if (number >biggest )
  23.                 {
  24.                     biggest = number;
  25.  
  26.                 }
  27.                
  28.                 sum = sum + number;
  29.             }
  30.             if (biggest == (sum-biggest))
  31.             {
  32.                 Console.WriteLine($"Yes");
  33.                 Console.WriteLine($"Sum = {Math.Abs(biggest)}");
  34.             }
  35.             else
  36.             {
  37.                 Console.WriteLine($"No");
  38.                 Console.WriteLine($"Diff = {Math.Abs((sum-biggest)-biggest)}");
  39.             }
  40.            
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement