3. feladat a, b befejezve
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -28,7 +28,7 @@
|
||||
"RelativeDocumentMoniker": "Jatekos.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_2\\Program\\Jatekos.cs",
|
||||
"RelativeToolTip": "Jatekos.cs",
|
||||
"ViewState": "AgIAAAQAAAAAAAAAAAAiwCcAAAAvAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAUAAAAAAAAAAAAAABAAAAAPAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-05T17:40:39.379Z",
|
||||
"EditorCaption": ""
|
||||
@@ -41,7 +41,7 @@
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_2\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAM8AAAAAAAAAAAAAAOcAAABHAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAFAAAAAAAAAAAAAuwH4AAAANAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-05T11:40:10.358Z",
|
||||
"EditorCaption": ""
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"RelativeDocumentMoniker": "Jatekos.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_2\\Program\\Jatekos.cs",
|
||||
"RelativeToolTip": "Jatekos.cs",
|
||||
"ViewState": "AgIAAAQAAAAAAAAAAAAiwCcAAAAvAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAUAAAAAAAAAAAAAABAAAAAPAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-05T17:40:39.379Z",
|
||||
"EditorCaption": ""
|
||||
@@ -41,7 +41,7 @@
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_2\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAOoAAAAAAAAAAADwv/UAAAAQAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAFAAAAAAAAAAAAAuwH4AAAAMAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-05T11:40:10.358Z",
|
||||
"EditorCaption": ""
|
||||
|
||||
@@ -38,5 +38,7 @@ namespace Program
|
||||
|
||||
public int[] dobasokFull { get; set; }
|
||||
public int[] dontesekFull { get; set; }
|
||||
|
||||
public List<int[]> asztalok = new List<int[]>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,164 @@ namespace Program
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Feladat1();
|
||||
Feladat2();
|
||||
//Feladat2();
|
||||
Feladat3();
|
||||
}
|
||||
|
||||
static void Feladat3()
|
||||
{
|
||||
Dictionary<char, int> lookUpTable = new Dictionary<char, int>();
|
||||
|
||||
//csökkentett értékek, mert programozásban ugye nem egytől számolunk
|
||||
lookUpTable.Add('A', 0);
|
||||
lookUpTable.Add('E', 1);
|
||||
lookUpTable.Add('I', 2);
|
||||
lookUpTable.Add('O', 3);
|
||||
lookUpTable.Add('U', 4);
|
||||
|
||||
char[,] tablazat = CreateAlphabetMatrix();
|
||||
|
||||
PrintMatrix(tablazat);
|
||||
|
||||
string path = @"..\..\..\Sources\szoveg.txt";
|
||||
var data = File.ReadAllLines(path);
|
||||
|
||||
List<string> secretWords = new List<string>();
|
||||
|
||||
foreach (var line in data)
|
||||
{
|
||||
var currentWords = line.Split(' ');
|
||||
foreach (var item in currentWords)
|
||||
{
|
||||
secretWords.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
List<string> solvedWords = new List<string>();
|
||||
|
||||
bool coordsShouldSwitch = false;
|
||||
|
||||
foreach (var secret in secretWords)
|
||||
{
|
||||
List<char> solvedChars = new List<char>();
|
||||
for (int i = 0; i < secret.Length; i+=2)
|
||||
{
|
||||
if (coordsShouldSwitch)
|
||||
{
|
||||
int row = lookUpTable[secret[i + 1]];
|
||||
int col = lookUpTable[secret[i]];
|
||||
|
||||
solvedChars.Add(tablazat[row, col]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int row = lookUpTable[secret[i]];
|
||||
int col = lookUpTable[secret[i + 1]];
|
||||
|
||||
solvedChars.Add(tablazat[row, col]);
|
||||
}
|
||||
|
||||
coordsShouldSwitch = !coordsShouldSwitch;
|
||||
}
|
||||
|
||||
solvedWords.Add(new string(solvedChars.ToArray()));
|
||||
}
|
||||
|
||||
// a feladat
|
||||
|
||||
foreach (var solved in solvedWords)
|
||||
{
|
||||
Console.WriteLine(solved);
|
||||
}
|
||||
|
||||
int indexOfFirstWordWithQInIt = solvedWords.IndexOf(solvedWords.First(x => x.Contains('Q')));
|
||||
int indexOfLastWordWithQInIt = solvedWords.IndexOf(solvedWords.Last(x => x.Contains('Q')));
|
||||
|
||||
|
||||
|
||||
//Console.WriteLine(solvedWords[indexOfFirstWordWithQInIt]);
|
||||
//Console.WriteLine(solvedWords[indexOfLastWordWithQInIt]);
|
||||
|
||||
Console.WriteLine($"A szövegben lévő Q karakteres szavak közötti max távolság: {indexOfLastWordWithQInIt - indexOfFirstWordWithQInIt - 1}");
|
||||
|
||||
// b feladat
|
||||
|
||||
string pathToSzoveg2 = @"..\..\..\Sources\szoveg2.txt";
|
||||
var szoveg2Data = File.ReadAllText(pathToSzoveg2);
|
||||
|
||||
char[] vowelsLookUp = { 'A', 'E', 'I', 'O', 'U' };
|
||||
|
||||
List<char> vowels = new List<char>();
|
||||
|
||||
foreach (char c in szoveg2Data)
|
||||
{
|
||||
if (vowelsLookUp.Contains(c))
|
||||
{
|
||||
vowels.Add(c);
|
||||
}
|
||||
}
|
||||
|
||||
string feladatBString = new string(vowels.ToArray());
|
||||
|
||||
|
||||
|
||||
List<char> solvedCharsForFeladatB = new List<char>();
|
||||
for (int i = 0; i < feladatBString.Length; i += 2)
|
||||
{
|
||||
int row = lookUpTable[feladatBString[i]];
|
||||
int col = lookUpTable[feladatBString[i + 1]];
|
||||
|
||||
solvedCharsForFeladatB.Add(tablazat[row, col]);
|
||||
|
||||
}
|
||||
|
||||
Console.WriteLine(new string(solvedCharsForFeladatB.ToArray()));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static char[,] CreateAlphabetMatrix()
|
||||
{
|
||||
char[,] matrix = new char[5, 5];
|
||||
List<char> alphabet = new List<char>();
|
||||
|
||||
// Add letters A-Z except for 'W'
|
||||
for (char c = 'A'; c <= 'Z'; c++)
|
||||
{
|
||||
if (c != 'W')
|
||||
{
|
||||
alphabet.Add(c);
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the matrix with the alphabet
|
||||
int index = 0;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
matrix[i, j] = alphabet[index];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
static void PrintMatrix(char[,] matrix)
|
||||
{
|
||||
for (int i = 0; i < matrix.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < matrix.GetLength(1); j++)
|
||||
{
|
||||
Console.Write(matrix[i, j] + " ");
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Feladat2()
|
||||
{
|
||||
string path = @"..\..\..\Sources\dobasok.txt";
|
||||
@@ -224,32 +379,105 @@ namespace Program
|
||||
// e feladat
|
||||
foreach (var kor in korok)
|
||||
{
|
||||
IntArrKiir(kor.dobasokFull);
|
||||
IntArrKiir(kor.dontesekFull);
|
||||
Console.WriteLine("---------");
|
||||
List<int[]> asztalok = new List<int[]>();
|
||||
List<int> currentAsztal = new List<int>();
|
||||
List<int> currentDontesek = new List<int>();
|
||||
|
||||
int iter = 0;
|
||||
|
||||
while (iter < kor.dobasokFull.Length)
|
||||
{
|
||||
while (currentAsztal.Count != 5)
|
||||
{
|
||||
currentAsztal.Add(kor.dobasokFull[iter]);
|
||||
currentDontesek.Add(kor.dontesekFull[iter]);
|
||||
|
||||
iter++;
|
||||
}
|
||||
|
||||
if (currentAsztal.Count == 5)
|
||||
{
|
||||
asztalok.Add(currentAsztal.ToArray());
|
||||
List<int> tempAsztal = new List<int>(currentAsztal);
|
||||
List<int> tempDontesek = new List<int>(currentDontesek);
|
||||
currentAsztal.Clear();
|
||||
currentDontesek.Clear();
|
||||
|
||||
for (int i = 0; i < tempAsztal.Count; i++)
|
||||
{
|
||||
if (tempDontesek[i] == 1)
|
||||
{
|
||||
currentAsztal.Add((int)tempAsztal[i]);
|
||||
currentDontesek.Add(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kor.asztalok = asztalok;
|
||||
}
|
||||
|
||||
Console.WriteLine(CountPairs(new int[] { 2, 2, 3, 3, 4 }));
|
||||
int pairs = 0;
|
||||
|
||||
foreach (var kor in korok)
|
||||
{
|
||||
foreach (var asztal in kor.asztalok)
|
||||
{
|
||||
foreach (var item in asztal)
|
||||
{
|
||||
Console.Write($"{item} ");
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
pairs += CountPairs(asztal);
|
||||
}
|
||||
Console.WriteLine("-----");
|
||||
}
|
||||
|
||||
Console.WriteLine($"Párok száma: {pairs}");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int GetAllPairs(List<int> dobasok, List<int> dontesek)
|
||||
static void PopulateAsztal(Kor kor)
|
||||
{
|
||||
int pairs = 0;
|
||||
List<int[]> asztalok = new List<int[]>();
|
||||
List<int> currentAsztal = new List<int>();
|
||||
List<int> currentDontesek = new List<int>();
|
||||
|
||||
List<int> asztalok = new List<int>();
|
||||
int iter = 0;
|
||||
|
||||
foreach (var dobas in dobasok)
|
||||
while (iter != kor.dobasokFull.Length - 1)
|
||||
{
|
||||
|
||||
while (currentAsztal.Count != 5)
|
||||
{
|
||||
currentAsztal.Add(kor.dobasokFull[iter]);
|
||||
currentDontesek.Add(kor.dontesekFull[iter]);
|
||||
|
||||
iter++;
|
||||
}
|
||||
|
||||
if (currentAsztal.Count == 5)
|
||||
{
|
||||
asztalok.Add(currentAsztal.ToArray());
|
||||
List<int> tempAsztal = currentAsztal;
|
||||
List<int> tempDontesek = currentDontesek;
|
||||
currentAsztal.Clear();
|
||||
currentDontesek.Clear();
|
||||
|
||||
for (int i = 0; i < tempAsztal.Count; i++)
|
||||
{
|
||||
if (tempDontesek[i] == 1)
|
||||
{
|
||||
currentAsztal.Add((int)tempAsztal[i]);
|
||||
currentDontesek.Add(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
static int CountPairs(int[] dobasok)
|
||||
{
|
||||
int pairs = 0;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user