-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo34.cs
56 lines (48 loc) · 1.41 KB
/
algo34.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
namespace HelloWorld
{
class Program
{
class Algorithm
{
public static int[] minMax(int[] lst)
{
int x = lst.Min();
int y = lst.Max();
int[] result = new int[2];
result[0] = x;
result[1] = y;
return result;
}
}
class MinMax
{
public static int[] minMax(int[] lst)
{
int x = lst.Min();
int y = lst.Max();
return new int[] { x, y };
}
}
static void Main(string[] args)
{
int[] dizi = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int[] sonuc = Algorithm.minMax(dizi);
// Çözüm 1: Foreach döngüsü ile yazdırma
foreach (int i in sonuc)
{
Console.WriteLine(i);
}
// Çözüm 2: ToString() ile yazdırma
Console.WriteLine(string.Join(", ", sonuc));
int[] sonuc2 = MinMax.minMax(dizi);
Console.WriteLine(string.Join(", ", sonuc2));
}
}
}