Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Дадена е огърлица от черни и бели мъниста, така че няма две съседни черни мъниста.
- // При зададени w-бели и b-черни мъниста да се отпечатат всички възможни огърлици.
- #include <iostream>
- #include <string>
- #include <algorithm>
- int main()
- {
- int black, white;
- std::cout << "Enter the number of BLACK beads: ";
- std::cin >> black;
- std::cout << "Enter the number of WHITE beads: ";
- std::cin >> white;
- std::string necklace(black, 'B');
- necklace.append(white, 'W');
- do
- {
- if (necklace.find("BB") == std::string::npos)
- std::cout << necklace << std::endl;
- } while (std::next_permutation(necklace.begin(), necklace.end()));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment