Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Runtime;
- namespace CsharpCourse
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int[] arr = new int[n];
- for(int i = 0; i<arr.Length; i++)
- {
- arr[i] = int.Parse(Console.ReadLine());
- }
- CalcAvg(arr);
- CalcAvg(arr , printSum: true);
- }
- static double CalcAvg(int[]arr , bool printAvg = false , bool printSum = false )
- {
- int sum = 0;
- foreach (int i in arr)
- {
- sum += i;
- }
- double avg = sum / arr.Length;
- if(printAvg) {
- Console.WriteLine(avg);
- }
- if (printSum)
- {
- Console.WriteLine(sum);
- }
- return avg;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement