cfrank2000
Well-known member
- Joined
- Mar 6, 2021
- Messages
- 71
- Programming Experience
- Beginner
metjelentes:
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
namespace metjelentes
{
using System;
class mystruct
{
public string telepulesKod { get; set; }
public string[] mertErtekek { get; set; }
public string[] ertekek { get; set; }
public int atlaghm { get; set; }
public int Minhm { get; set; }
public int Maxhm { get; set; }
}
class adatok0
{
public string telepules { get; set; }
public string ido { get; set; }
public string szeliranyes_erosseg { get; set; }
public int homerseklet { get; set; }
public int sorszam { get; set; }
public int ertekek { get; set; }
}
class beolvasas
{
int db = -1;
string ido = "";
string utolsomeres = "";
int kertszam = 0;
int maxhom = 0;
public int minhom = 0;
int hom = 0;
int maxindex = 0;
int hossz = 0;
string kerttelepules = "";
public List<adatok0> lista = new List<adatok0>();
public List<int> homersekletlista = new List<int>();
public List<string> telepulesek = new List<string>();
public List<string[]> idopont = new List<string[]>(2);
public void beolvas()
{
string olvas = @"c:\Users\Public\textfiles\tavirathu13.txt";
using (StreamReader sr = new StreamReader(olvas, Encoding.Default))
{
//StreamReader sr = new StreamReader(olvas, Encoding.Default);
//List<adatok> lista = new List<adatok>();
while (!sr.EndOfStream)
{
string[] sor = sr.ReadLine().Split(' ');
//string[] elemek = sor.Split(' ');
adatok0 adat = new adatok0();
adat.telepules = sor[0];
adat.ido = sor[1];
adat.szeliranyes_erosseg = sor[2];
adat.homerseklet = Int32.Parse(sor[3]);
lista.Add(adat);
db++;
adat.sorszam = db;
}
Random rd = new Random();
kertszam = rd.Next(1, db);
hossz = db;
}
}
public void szamol()
{
int n = -1;
foreach (adatok0 dt in lista)
{ n++;
if (n == kertszam)
{
kerttelepules = dt.telepules;
ido = dt.ido;
}
}
n = 0;
int m = 0;
foreach (adatok0 dt in lista)
{
//m++;
//maxindex = m;
if (lista[kertszam].telepules == dt.telepules)
{
ido = dt.ido;
// Console.WriteLine(" m " + m + " telepules " + kerttelepules + " " + ido + " " + hom);
hom = dt.homerseklet;
homersekletlista.Add(hom);
homersekletlista.Sort();
}
utolsomeres = ido;
}
//Console.WriteLine(" n " + n + " ido " + utolsomeres);
foreach (int ct in homersekletlista)
{
//Console.WriteLine(" homerseklet " +ct);
maxhom = ct;
}
minhom = homersekletlista[0];
//Console.WriteLine(" min homersekle " + minhom);
//maxhom = homersekletlista[maxindex-1];//
//Console.WriteLine(" max homersekle " + maxhom);
/*
/* */
}
//List<int> a = new List<int>();
int[] a2 = new int[900];
int i = 0;
int j = 0;
int k = -1;
string[] tomb = new string[900];
List<mystruct> tmb2 = new List<mystruct>();
List<int> lst1 = new List<int>();
List<int> lst2 = new List<int>();
int[,] Vektor = new int[100, 400];
// hossz = str1.Length;
public void valogat()
{
for (i = 0; i < hossz; i++)
{
for (j = 0; j < hossz; j++)
{
if (lista[j].telepules == lista[i].telepules)
{
a2[j] += 1;
if (a2[j] < 2)
{
//mystruct myrek = new mystruct();
//tomb[i] = Convert.ToString(str1[i]);
// myrek.kar = lista[j].telepules;
k = k + 1;
tomb[i]= lista[i].telepules;
}
else
{
tomb[i] = "empty";
}
}
// Console.WriteLine(" " + tomb[i]);
}
//Console.WriteLine(" tomb[ " + i + " ] " + tomb[i]);
}
Console.WriteLine(db + " db ");
for (i=0;i<db;i++)
{
//Console.WriteLine(db + " tomb[ " + i + " ] " + tomb[i]);
if (tomb[i] != "empty")
{
mystruct mydata1 = new mystruct();
mydata1.telepulesKod = tomb[i];
Console.WriteLine(" "+db+ " tomb[ " + i + " ] " + mydata1.telepulesKod);
tmb2.Add(mydata1);
if (lista[j].ido.Substring(0, 2) == ora[l].ToString() == true)
{
if (lista[j].homerseklet > 0)
{
// Console.Write(lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
Vektor[i, j] = lista[j].homerseklet;
lst1.Add(Vektor[i, j]);
}
}
}
}
foreach (mystruct dt3 in tmb2)
{
Console.WriteLine(" tmb2[ ] " + dt3.telepulesKod);
}
}
int[] ora = new int[4] { 1, 7, 13, 19 };
int l = 0;
//List<int[,]> vektor = new List<int[,]>();
public void meresek()
{
Console.WriteLine(" 1 ");
Console.WriteLine(" tmb2 " + tmb2.Count);
Console.WriteLine(" 2 ");
for (int i3=0;i3< tmb2.Count; i3++)
{
Console.WriteLine(" ");
Console.WriteLine(" " + tmb2.Count +" "+ tmb2[i3].telepulesKod);
Console.WriteLine(" ");
for (j = 0; j < db; j++)
{
if (tmb2[i3].telepulesKod == lista[j].telepules)
{
// Console.Write(" " + lista[j].homerseklet);
for (l=0;l<4;l++)
{
/* */
if (lista[j].ido.Substring(0, 2)==ora[l].ToString() == true)
{
if (lista[j].homerseklet > 0 )
{
mystruct rek1 = new mystruct;
List<adatok0> mert1 = new List<adatok0>();
// mystruct merthom = new mystruct();
//Console.Write(" j "+j+" "+lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
Console.Write( " " + lista[j].homerseklet + " fok ");
Vektor[i3, j] = lista[j].homerseklet;
lst1.Add(Vektor[i3, j]);
rek1.ertekek[j] = lista[j].homerseklet;
mert1[].ertekek.Add(lista[j].homerseklet.ToString());
}
//Console.Write(" ");
}
}
}
}
//Console.WriteLine(" ");
}
Console.WriteLine(" ");
// foreach (int a1 in lst1)
// {
// Console.Write(" " + a1);
// }
/// lst1.Clear();
}
int i1 = 0;
int j1 = 0;
public void kiiras()
{
/*
for (i1 = 0; i1 < 100; i1++)
{
for (j1 = 0; j1 < db; j1++)
{ if (Vektor[i1, j1] != 0)
{
//Array.Sort();
Console.Write(" v " + Vektor[i1, j1]);
}
}
Console.WriteLine(" ");
}
*/
for (int i = 0; i<db; i++)
{
Console.WriteLine(" ");
// rekordlista adat = new rekordlista();
Console.WriteLine(
" Sorszam " + lista[i].sorszam +
" Telepules " + lista[i].telepules +
" Ido " + lista[i].ido +
" Szelirany es_erosseg " + lista[i].szeliranyes_erosseg +
" Homerseklet " + lista[i].homerseklet
);
//fordulo = fordulo + Int32.Parse(rlista[i].fordulo);
//telitalalatok = telitalalatok + Int32.Parse(rlista[i].Ndarab13p1talalat);
//osszeg = osszeg + rlista[i].ossznyeremeny;
}
Console.WriteLine(" A rekordok szama db " + db);
Console.WriteLine(" 2. Feladat ");
Console.WriteLine(" A kert kod " + kertszam + " Telepules " + lista[kertszam].telepules+ " Ido " + lista[kertszam].ido);
Console.WriteLine(" A kert telepules kod " + kerttelepules);
Console.WriteLine(" Az utolso meresi adat " + utolsomeres);
Console.WriteLine(" 3. Feladat ");
Console.WriteLine(" A mert homerseklet maximum "+maxhom+ " Minimum homerseklet "+minhom);
Console.WriteLine(" 4. Feladat ");
foreach (adatok0 dt in lista )
{
if ("00000" == dt.szeliranyes_erosseg)
{
Console.WriteLine(" szelcsend " + dt.telepules+" "+dt.ido);
}
}
Console.WriteLine(" 5. Feladat ");
Console.WriteLine(" Szereplo Telepulesek kodja ");
foreach (mystruct dt3 in tmb2)
{
Console.WriteLine(" Az adott Telepules " + dt3.telepulesKod);
}
}
}
class Program
{
static void Main(string[] args)
{
beolvasas kiir1 = new beolvasas();
kiir1.beolvas();
kiir1.szamol();
kiir1.valogat();
kiir1.meresek();
kiir1.kiiras();
//Console.WriteLine("Hello World!");
}
}
}