Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Two_Numbers_Sum
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int y = int.Parse(Console.ReadLine());
- int counter = 0;
- int j1 = 0;
- int i1 = 0;
- int countr = 0;
- for (int i = n; i >= m; i--)
- {
- for (int j = n; j >= m; j--)
- {
- if (i1 + j1 == y)
- {
- break;
- }
- countr++;
- if (i + j ==y)
- {
- i1 = i;
- j1 = j;
- break;
- }
- else
- {
- counter++;
- }
- }
- }
- if (i1 + j1 == y)
- {
- Console.WriteLine("Combination N:{0} ({1} + {2} = {3})", countr,i1, j1, y);
- }
- else
- {
- Console.WriteLine("{0} combinations - neither equals {1}", counter, y);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment