Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- //Write a program, which prints all unique pairs in an array of integers whose sum is equal to a given number.
- int[] arr = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- //result=0;
- int num = int.Parse(Console.ReadLine());
- for(int i =0; i< arr.Length-1;i++)
- {
- for(int j=i+1; j<arr.Length;j++)
- {
- if(arr[i] + arr[j]==num)
- {
- Console.WriteLine($"{arr[i]} {arr[j]}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement