Created
June 6, 2023 14:11
-
-
Save mormegil-cz/037be8abf258baf064c793c748028046 to your computer and use it in GitHub Desktop.
Příklad normální implementace v dnešním jazyce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record Osoba(string Ident, string PrijmeniJmeno, int RokNarozeni, decimal KcDuchodu); | |
record CteniKartotekyResults(int Pocet, decimal Soucet); | |
void Main() | |
{ | |
var results = CteniKartoteky(ParseDuchody(File.ReadLines(@"duchody.txt"))); | |
var prumer = Math.Round(results.Soucet / results.Pocet); | |
Console.WriteLine($"Pocet: {results.Pocet}, Prumer: {prumer}"); | |
} | |
IEnumerable<Osoba> ParseDuchody(IEnumerable<string> lines) => lines.Select( | |
line => new Osoba( | |
line.Substring(0, 10), | |
line.Substring(10, 50), | |
Int32.Parse(line.Substring(60, 4)), | |
Int32.Parse(line.Substring(64, 6)) | |
) | |
); | |
CteniKartotekyResults CteniKartoteky(IEnumerable<Osoba> duchody) | |
{ | |
var pocet = 0; | |
var soucet = 0m; | |
foreach(var osoba in duchody) | |
{ | |
if (osoba.RokNarozeni + 85 == 2023) | |
{ | |
++pocet; | |
soucet += osoba.KcDuchodu; | |
} | |
} | |
return new(pocet, soucet); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Viz https://www.seznamzpravy.cz/clanek/domaci-zivot-v-cesku-system-z-dob-dernych-stitku-duchody-v-cesku-zpracovava-program-z-50-let-231952 (a jmenovitě https://d39-a.sdn.cz/d_39/c_img_QM_x/F7ARG/cobol-programovaci-jazyk.png?fl=cro,0,0,738,1284%7Cres,1280,,1%7Cwebp,75)