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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> lista = new List<int>();
- int i = 1, a;
- do
- {
- Console.Write("Adja meg a(z) {0}. pozitív számot: ", i++);
- a = Convert.ToInt32(Console.ReadLine());
- if (a != 0)
- {
- lista.Add(a);
- }
- } while (a > 0);
- if(lista.Count > 0)
- {
- Console.WriteLine("A legkisebb szám: {0}", lista.Min());
- Console.WriteLine("A legnagyobb szám: {0}", lista.Max());
- Console.WriteLine("Átlaguk: {0}", (double)lista.Average());
- Console.WriteLine("Összegük: {0}", lista.Sum());
- lista.Sort();
- foreach (int k in lista)
- {
- Console.Write("{0} ", k);
- }
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement