Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vegyes.txt
- 120;IPv4;Router
- 180;192;20
- Switch;88;35
- IPv6;38;2
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace vegyes
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> szamok = new List<int>();
- List<string> szavak = new List<string>();
- string[] sorok = File.ReadAllLines("vegyes.txt");
- foreach (var sor in sorok)
- {
- string[] adatok = sor.Split(';');
- foreach (var adat in adatok)
- {
- try
- {
- int sz = int.Parse(adat);
- szamok.Add( sz );
- }
- catch (Exception)
- {
- szavak.Add(adat);
- }
- }
- }
- Console.WriteLine("Szavak:");
- foreach (var szo in szavak)
- {
- Console.WriteLine( " "+szo );
- }
- Console.WriteLine();
- Console.WriteLine("Számok:");
- Console.WriteLine(" Összeg: "+szamok.Sum());
- Console.WriteLine(" Minimum: "+szamok.Min());
- Console.WriteLine(" Maximum: "+szamok.Max());
- Console.WriteLine(" Átlag: "+Math.Round( szamok.Average(),2) );
- szamok.Sort();
- Console.Write("Sorrendben: ");
- foreach (var sz in szamok)
- {
- Console.Write( sz+" " );
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement