using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace gyakorlás_20190328 { class Program { struct rekord { public char szoveg; public int szam; } static rekord[] tomb = new rekord[10]; static rekord[] valogatas = new rekord[10]; static int i; static Random v = new Random(); static void Main(string[] args) { //tömb előállítása for (i = 0; i < 10; i++) { tomb[i].szam = v.Next(1, 10); tomb[i].szoveg = Convert.ToChar(tomb[i].szam + 64); Console.Write("{0} ", tomb[i].szam); Console.Write("{0} ", tomb[i].szoveg); Console.WriteLine(); } Console.WriteLine(); //szétválogatás Dorina ötletei alapján int db,j; bool marvolt; valogatas[0].szoveg = tomb[0].szoveg; db = 1; for (i = 1; i < 10; i++) { marvolt = false; for (j = 0; j < db; j++) { if (valogatas[j].szoveg == tomb[i].szoveg) { marvolt = true; } } if (!marvolt) { valogatas[db].szoveg = tomb[i].szoveg; db++; } } //kiírás for (i = 0; i < db;i++ ) { Console.Write("{0} ",valogatas[i].szoveg); } Console.ReadKey(); } } }