-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathCanBalance.cs
50 lines (49 loc) · 1.33 KB
/
CanBalance.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication180
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the Maximum Range for the array:");
int N = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n");
int[] a = new int[N];
Console.WriteLine("Enter the values:");
int i, j,sum1=0,sum2=0;
for (i = 0; i < N; i++)
{
a[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("\n");
Console.WriteLine("The values entered are:");
for (i = 0; i < N; i++)
{
Console.Write("{0} ", a[i]);
}
Console.WriteLine("\n");
for (i = 0; i < N / 2; i++)
{
sum1 = sum1 + a[i];
}
for (j = N / 2; j < N; j++)
{
sum2 = sum2 + a[j];
}
Console.WriteLine("\n");
if (sum1 == sum2)
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
}
}