mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 04:16:32 +01:00
sleepy
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace OE.ALGA.Optimalizalas
|
namespace OE.ALGA.Optimalizalas
|
||||||
@@ -54,4 +55,44 @@ namespace OE.ALGA.Optimalizalas
|
|||||||
return (OsszSuly(pakolas) <= Wmax);
|
return (OsszSuly(pakolas) <= Wmax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class NyersEro<T>
|
||||||
|
{
|
||||||
|
int m;
|
||||||
|
Func<int, T> generator;
|
||||||
|
Func<T, int> josag;
|
||||||
|
int lepesszam;
|
||||||
|
public int Lepesszam
|
||||||
|
{
|
||||||
|
get { return lepesszam; }
|
||||||
|
}
|
||||||
|
public NyersEro(int m, Func<int, T> generator, Func<T, int> josag)
|
||||||
|
{
|
||||||
|
this.m = m;
|
||||||
|
this.generator = generator;
|
||||||
|
this.josag = josag;
|
||||||
|
}
|
||||||
|
public T OptimalisMegoldas()
|
||||||
|
{
|
||||||
|
T[] megoldasok = new T[m];
|
||||||
|
for (int i = 0; i < m; i++)
|
||||||
|
{
|
||||||
|
megoldasok[i] = generator(i);
|
||||||
|
}
|
||||||
|
int[] ertekek = new int[m];
|
||||||
|
int maxindex = 0;
|
||||||
|
for (int i = 0; i < m; i++)
|
||||||
|
{
|
||||||
|
ertekek[i] = josag(megoldasok[i]);
|
||||||
|
if (ertekek[maxindex] < ertekek[i])
|
||||||
|
{
|
||||||
|
maxindex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return megoldasok[maxindex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class NyersEroHatizsakPakolas
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user