Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _11._5_Different_Numbers
- {
- class FiveDifferentNumbers
- {
- static void Main(string[] args)
- {
- //You will be given two numbers – a and b. Generate five numbers - n1, n2, n3, n4, n5, for which the following conditions
- //are true: a ≤ n1 < n2 < n3 < n4 < n5 ≤ b. If there is no number in the given interval, which satisfies the conditions –
- //print “No”.
- int first = int.Parse(Console.ReadLine());
- int second = int.Parse(Console.ReadLine());
- if (first + 4 >= second)
- {
- Console.WriteLine("No");
- return;
- }
- for (int i = first; i <= second-4; i++)
- {
- for (int j = first+1; j <= second-3; j++)
- {
- for (int k = first+2; k <= second-2; k++)
- {
- for (int l = first+3; l <=second-1; l++)
- {
- for (int m = first+4; m <= second; m++)
- {
- if (i<j && j<k && k<l && l<m)
- {
- Console.WriteLine($"{i} {j} {k} {l} {m}");
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment