grigorb57

Izvrashtenie

Feb 27th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 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 ConsoleApp39
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double sum = double.MinValue;
  14.             var n = new[] { $"{sum}" };
  15.  
  16.             double biggestNum = double.MinValue;
  17.  
  18.             Console.Write("Enter the number of numbers: ");
  19.             int numbers = int.Parse(Console.ReadLine());
  20.             Console.WriteLine("Enter the numbers.");
  21.             for (var i = 0; i < numbers; i++)
  22.             {
  23.                 int num = int.Parse(Console.ReadLine());
  24.                 sum += num;
  25.  
  26.                 if (num > biggestNum)
  27.                 {
  28.                     biggestNum = num;
  29.                 }
  30.             }
  31.             if (biggestNum == sum)
  32.             {
  33.                 Console.WriteLine("They are equal, and the result is:" + sum);
  34.             }
  35.             else if (biggestNum > sum)
  36.             {
  37.                 Console.WriteLine($"Biggest number is: {biggestNum}");
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment