using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
using
System.Threading.Tasks;
using System.IO;
namespace
ConsoleApplication1
{
class
Program
{
static void Main(string[]
args)
{
//lista
generálása
List<double> szamok = new
List<double>();
Random rnd = new
Random();
int n = szamok.Count;
for (int i = 0; i < n;
i++)
{
if (i % 2 == 0)
szamok.Add(rnd.Next(10, 51));
else szamok.Add(rnd.Next(40,81));
}
//Egész
számítása átlaga
int sum = 0;
foreach (int x in szamok)
sum = sum + x;
Console.WriteLine("Átlag
= {0}", (double) sum / n);
//Lista feltöltése
számokkal fájlból
List<double> szamok1 =
new List<double>();
StreamReader f = new
StreamReader(@"szamok.txt", Encoding.Default);
while (f.EndOfStream ==
false)
{
string s = f.ReadLine();
if (s.Trim().Length
== 0) break;
double d =
double.Parse( s.Replace('.',','));
}
f.Close();
}
}