solved fordulo_2 feladat_1
This commit is contained in:
151
fordulo_2/Program/Program.cs
Normal file
151
fordulo_2/Program/Program.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Program
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Feladat1();
|
||||
Feladat2();
|
||||
|
||||
}
|
||||
|
||||
static void Feladat2()
|
||||
{
|
||||
string path = @"..\..\..\Sources\dobasok.txt";
|
||||
string path2 = @"..\..\..\Sources\dontesek.txt";
|
||||
|
||||
var dobasok = new List<int>();
|
||||
var dontesek = new List<int>();
|
||||
|
||||
//dobasok
|
||||
|
||||
var data = File.ReadAllText(path).Trim();
|
||||
string splitable = "";
|
||||
foreach (char c in data)
|
||||
{
|
||||
splitable += " " + c.ToString();
|
||||
}
|
||||
|
||||
var dobasokData = splitable.Trim().Split(' ');
|
||||
foreach (var item in dobasokData)
|
||||
{
|
||||
dobasok.Add(Convert.ToInt32(item));
|
||||
}
|
||||
|
||||
|
||||
//dontesek
|
||||
|
||||
var data2 = File.ReadAllText(path2).Trim();
|
||||
string splitable2 = "";
|
||||
foreach (char c in data2)
|
||||
{
|
||||
splitable2 += " " + c.ToString();
|
||||
}
|
||||
|
||||
var dontesekData = splitable2.Trim().Split(' ');
|
||||
foreach (var item in dontesekData)
|
||||
{
|
||||
dontesek.Add(Convert.ToInt32(item));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void Feladat1()
|
||||
{
|
||||
string path = @"..\..\..\Sources\idopontok.txt";
|
||||
|
||||
var idopontok = new List<Idopont>();
|
||||
|
||||
var data = File.ReadAllLines(path);
|
||||
foreach (var line in data)
|
||||
{
|
||||
var parts = line.Split(' ');
|
||||
Idopont idopont = new Idopont(int.Parse(parts[0]), int.Parse(parts[1]));
|
||||
idopontok.Add(idopont);
|
||||
}
|
||||
|
||||
|
||||
foreach (var idopont in idopontok)
|
||||
{
|
||||
Console.WriteLine($"{idopont.Name}, {idopont.ClockAngle()}°");
|
||||
}
|
||||
|
||||
Console.WriteLine($"Legnagyobb szögű időpont: {idopontok.OrderByDescending(x => x.Angle).First().Name}");
|
||||
|
||||
|
||||
// nem biztos, hogy jó
|
||||
List<double> angleDifferences = new List<double>();
|
||||
for (int i = 0; i < idopontok.Count - 1; i++)
|
||||
{
|
||||
angleDifferences.Add(Math.Abs(idopontok[i].Angle - idopontok[i + 1].Angle));
|
||||
}
|
||||
|
||||
Console.WriteLine($"Legkisebb változás: {angleDifferences.Min()}°");
|
||||
|
||||
var idopontok2 = new List<Idopont>();
|
||||
int napok = 5;
|
||||
|
||||
for (int i = 0; i < napok; i++)
|
||||
{
|
||||
for (int orak = 0; orak < 24; orak++)
|
||||
{
|
||||
for (int percek = 0; percek < 60; percek++)
|
||||
{
|
||||
Idopont idopont = new Idopont(orak, percek);
|
||||
idopont.ClockAngle();
|
||||
idopontok2.Add(idopont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string path2 = @"..\..\..\Sources\szogek.txt";
|
||||
|
||||
var data2 = File.ReadAllText(path2).Split(' ');
|
||||
List<double> anglesToLookFor = new List<double>();
|
||||
|
||||
|
||||
foreach (var item in data2)
|
||||
{
|
||||
string formattedItem = item.Replace('.', ',');
|
||||
anglesToLookFor.Add(Double.Parse(formattedItem));
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
int iterations = 0;
|
||||
int napokCounter = 0;
|
||||
|
||||
foreach (var item in idopontok2)
|
||||
{
|
||||
if (counter == anglesToLookFor.Count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (item.Angle == anglesToLookFor[counter])
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
|
||||
iterations++;
|
||||
|
||||
if (iterations == 1440)
|
||||
{
|
||||
napokCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"{napokCounter}|{idopontok2[iterations].Name}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user