ProgaOra/20230911/ConsoleApp1/Program.cs
2023-12-04 10:51:29 +01:00

121 lines
3.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApp1
{
class Program
{
static void Feladat1()
{
int n = 6;
int m = 2;
int[,] betuk = new int [n,m];
string asd = "bzbzbzauzguzbvukzbkjhbvjkhvta";
for (int i = 0; i < asd.Length; ++i)
{
char x = asd[i];
for (int z = 0; z < n; ++z)
{
if (x == Convert.ToChar(betuk[z, 0]))
{
betuk[z, 1]++;
break;
}
else
{
betuk[z, 0] = Convert.ToInt32(x);
betuk[z, 1]++;
break;
}
}
}
Console.WriteLine(Convert.ToChar(betuk[0, 0]));
Console.WriteLine(betuk[0, 1]);
Console.WriteLine(betuk[1, 0]);
Console.WriteLine(betuk[1, 1]);
for (int a = 0; a < n; ++a)
{
for (int b = 0; b < m; ++b)
{
Console.WriteLine(betuk[a, b]);
}
}
}
static void Feladat2()
{
FileStream fs = new FileStream("asd.txt", FileMode.Open);
StreamReader sr = new StreamReader(fs);
string str = sr.ReadToEnd();
var dict = new Dictionary<char, int>();
foreach (char c in str)
{
dict.TryGetValue(c, out int count);
dict[c] = ++count;
}
foreach (var pair in dict.OrderBy(r => r.Key))
{
Console.WriteLine(pair.Value + "x " + pair.Key + " (" + (int)pair.Key + ")");
}
sr.Close();
fs.Close();
}
static void Feladat3()
{
string egeszSzoveg;
char[] karakterek = { };
FileStream fs = new FileStream(@"C:\Users\szabomarton\Desktop\C#\allomanyok\asd2.txt", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs, Encoding.Default);
egeszSzoveg = sr.ReadToEnd();
int karakterIndex = 0;
int ennyivan = 0;
for (int i = 0; i < egeszSzoveg.Length; ++i)
{
if (!karakterek.Contains(egeszSzoveg[i]))
{
karakterek = karakterek.Append(egeszSzoveg[i]).ToArray();
}
}
Array.Sort(karakterek);
while (karakterIndex < karakterek.Length)
{
for (int i = 0; i < egeszSzoveg.Length; ++i)
{
if (egeszSzoveg[i] == karakterek[karakterIndex])
{
ennyivan++;
}
}
Console.WriteLine($"Ennyi {karakterek[karakterIndex]} van: {ennyivan}");
karakterIndex++;
ennyivan = 0;
}
sr.Close();
fs.Close();
}
static void Feladat4()
{
}
static void Main(string[] args)
{
Feladat4();
Console.ReadLine();
}
}
}