Commit 1ae0a26b authored by Uwe Wienkop's avatar Uwe Wienkop

Klimadaten

parent bc8aa5f2
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace _11Klimaerwaermung
{
......@@ -10,6 +11,30 @@ namespace _11Klimaerwaermung
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(@"..\..\Klimadaten.txt");
for (int jahr = 1956; jahr <= 2013; jahr++)
{
sr.ReadLine();
double tempSumme = 0;
int anz = 0;
while (!sr.EndOfStream)
{
string zeile = sr.ReadLine();
string[] daten = zeile.Split(';');
if (daten.Length == 18)
{
if (daten[1].StartsWith(jahr.ToString()))
{
tempSumme += Convert.ToDouble(daten[3].Replace('.', ','));
anz++;
}
}
}
Console.WriteLine($"Jahr: {jahr} Durchschnittstemp: {tempSumme / anz}, {anz} Einträge");
sr.BaseStream.Seek(0, SeekOrigin.Begin);
}
sr.Close();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment