update
This commit is contained in:
@@ -5,41 +5,13 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MinMax {
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
Random random = new Random();
|
||||
public class Program {
|
||||
public static void Main(string[] args) {
|
||||
|
||||
int[] arr = new int[Int32.MaxValue/8];
|
||||
Adat adat = new Adat();
|
||||
|
||||
//random elemek hozzaadasa a tombhoz
|
||||
for (int i = 0; i < arr.Length; i++) {
|
||||
arr[i] = random.Next(Int32.MinValue,Int32.MaxValue);
|
||||
}
|
||||
|
||||
|
||||
//tomb elemeinek kiiratasa
|
||||
/*for (int i = 0; i < arr.Length; i++) {
|
||||
Console.WriteLine(arr[i]);
|
||||
}*/
|
||||
|
||||
int min = Int32.MaxValue;
|
||||
int min_i = -1;
|
||||
int max = Int32.MinValue;
|
||||
int max_i = -1;
|
||||
|
||||
for (int i = 0; i < arr.Length; i++) {
|
||||
if(min > arr[i]) {
|
||||
min = arr[i];
|
||||
min_i = i;
|
||||
}
|
||||
if (max < arr[i]) {
|
||||
max = arr[i];
|
||||
max_i = i;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Min ertek: {0}, helye: {1}",min,min_i);
|
||||
Console.WriteLine("Max ertek: {0}, helye: {1}", max, max_i);
|
||||
Console.WriteLine("Min: " + adat.min());
|
||||
Console.WriteLine("Max: " + adat.max());
|
||||
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user