Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int n = Int32.Parse(Console.ReadLine());
  8.         int[] arr = new int[n];
  9.         int sum = 0;
  10.        
  11.         for (int i = 0; i < n; i++)
  12.         {
  13.             int num = Int32.Parse(Console.ReadLine());
  14.             arr[i] = num;
  15.             sum += num;
  16.         }  
  17.        
  18.         double avrg = (sum * 1.0) / n;
  19.         double avrgSum = avrg;
  20.         if (n > 1)
  21.         {
  22.             avrgSum += ((arr[1] + arr[n - 2]) * 1.0) / 2;
  23.         }
  24.        
  25.         Console.WriteLine(avrg);
  26.         Console.WriteLine(avrgSum);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement