Answer the question
In order to leave comments, you need to log in
What is the formula for the exhaustive search of two ranges algorithm?
Hello eagles! Help someone who fumbles in algorithms.
We need an algorithm to enumerate two ranges, for example, all options from the range a (1-10) to the range b (15-30) I started doing it myself, but I missed something in the code.
void comb2(int a, int b, int c, int d) // a,b,c,d - границы первого и второго диапазонов
{
for (int i = a; i < b; i++) // перебор первого диапазона
{ for (int j = a; j < b; j++)
cout << char(i) << char(j) << "\n"; }
for (int i = c; i < d; i++) // перебор второго диапазона
{ for (int j = c; j < d; j++)
cout << char(i) << char(j) << "\n"; }
for (int i = a; i < b; i++) // скрещенный перебор диапазонов
{ for (int j = c; j < d; j++)
cout << char(i) << char(j) << "\n"; }
for (int i = c; i < d; i++) // перевернутый скрещенный перебор диапазонов
{ for (int j = a; j < b; j++)
cout << char(i) << char(j) << "\n"; }
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question