ProgaOra/20230911/ConsoleApp2/Program.cs

55 lines
1.5 KiB
C#
Raw Normal View History

2023-12-04 09:51:29 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApp2
{
class Program
{
static void Feladat3()
{
string egeszSzoveg;
char[] karakterek = { };
FileStream fs = new FileStream(@"asdasd.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 Main(string[] args)
{
Feladat3();
Console.ReadLine();
}
}
}