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;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApp1
- {
- class Program
- {
- struct nevek
- {
- public string nev;
- public int evszam;
- }
- static List<nevek> lista = new List<nevek>();
- static void Main(string[] args)
- {
- nevek temp;
- StreamReader f = new StreamReader("nevek.txt");
- while (!f.EndOfStream)
- {
- string[] darabolt = f.ReadLine().Split(';');
- temp.nev = darabolt[0];
- temp.evszam = int.Parse(darabolt[1]);
- lista.Add(temp);
- }
- for (int i = 0; i < lista.Count; i++)
- {
- for (int j = 1; j < lista.Count; j++)
- {
- if (lista[j].evszam < lista[j-1].evszam)
- {
- temp = lista[j];
- lista[j] = lista[j-1];
- lista[j-1] = temp;
- }
- }
- }
- StreamWriter g = new StreamWriter("nevek2.txt");
- foreach (var item in lista)
- {
- Console.WriteLine(item.nev + " - " + item.evszam);
- g.WriteLine(item.nev + " - " + item.evszam);
- }
- g.Close();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement