-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBothSum.cs
More file actions
40 lines (37 loc) · 951 Bytes
/
BothSum.cs
File metadata and controls
40 lines (37 loc) · 951 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Codechallenge02
{
public class BothSum
{
public int SumArray(int[] array)
{
int length = array.Length;
for (int i = 0; i < array.Length; i++)
{
array[i] = Convert.ToInt32(Console.ReadLine());
}
int smallest = array[0];
int Largest = array[0];
for (int i = 0; i < length; i++)
{
if (smallest > array[i])
{
smallest = array[i];
}
}
for (int i = 0; i < length; i++)
{
if (Largest < array[i])
{
Largest = array[i];
}
}
int sum = Largest + smallest;
return sum;
}
}
}