-
Notifications
You must be signed in to change notification settings - Fork 0
/
PairElementsUserInput.cs
47 lines (43 loc) · 1.25 KB
/
PairElementsUserInput.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1.DemoA.NewFolder1
{
class PairElementsUserInput
{
public void acceptArray1Elts(int[] s)
{
Console.WriteLine("Enter the Array Vlaues");
for(int i = 0; i < s.Length; i++)
{
s[i] = int.Parse(Console.ReadLine());
}
}
int n;
public void PairWhoseSumIsGivenInt(int[] s)
{
for(int i = 0; i < s.Length; i++)
{
for (int j = 0; j <s.Length; i++)
{
if (n == s[i] + s[j])
{
Console.WriteLine($"({s[i]},{s[j]})");
}
}
}
}
static void Main(string[] args)
{
Console.WriteLine("Enter the Size Of Array");
int a = int.Parse(Console.ReadLine());
int[] s = new int[a];
// int[] b = { 52, 35, 65, 85, 95 };
PairElementsUserInput Peu = new PairElementsUserInput();
Peu.PairWhoseSumIsGivenInt(s);
Peu.acceptArray1Elts(s);
}
}
}