Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int liczba, zmienna = 0;
- double suma = 0;
- Console.WriteLine("Ile liczb chcesz wprowadzić: <2:20>");
- while (true)
- {
- if (int.TryParse(Console.ReadLine(), out liczba) && liczba >= 2 && liczba <= 20) break;
- else Console.WriteLine("Podaj poprawną liczbę z zakresu <2:20>");
- }
- for (int i = 0; i < liczba; i++)
- {
- while (true)
- {
- Console.Write("Podaj liczbę [{0}]= ", i + 1);
- if (int.TryParse(Console.ReadLine(), out zmienna)) break;
- else Console.WriteLine("Podaj poprawną liczbę całkowitą!");
- }
- suma += zmienna;
- }
- Console.WriteLine("Średnia arytmetyczna z zadanego ciągu liczb wynosi:{0}", suma/liczba);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement