Advertisement
ZazoTazo

Lab3-1

Nov 11th, 2020
552
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 Project_1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n, sum = 0, difference = 0;
  14.             Console.WriteLine("Enter size of array");
  15.             n = int.Parse(Console.ReadLine());
  16.             int[] array = new int[n];
  17.             Console.WriteLine("Please enter {0} numbers.", array.Length);
  18.             for(int i = 0; i < array.Length; i++)
  19.             {
  20.                 array[i] = int.Parse(Console.ReadLine());
  21.             }
  22.  
  23.             for (int i = 0; i < array.Length; i++) {
  24.                 sum += array[i];
  25.             }
  26.  
  27.             //ascending difference
  28.             for (int i = 0; i < array.Length; i++)
  29.             {
  30.                 difference -= array[i];
  31.             }
  32.  
  33.             Console.WriteLine("Sum = {0}\nDifference = {1}\nAverage = {2}\nMax = {3}\nMin = {4}", sum, difference, sum/array.Length, array.Max(), array.Min());
  34.            
  35.             Console.ReadLine();
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement