Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- const int n = 5;
- const int count = 4;
- int counter = 0;
- int arrayofelem[count] = { 0, 1, 2, 3 };
- int array[n];
- void perestanovka();
- int main(){
- perestanovka();
- return 0;
- }
- void perestanovka(){
- array[n - 1] += 1;
- for (int i = n - 1; i >= 0; i--) {
- if (array[i] > arrayofelem[count - 1]){
- array[i] = arrayofelem[0];
- if (i > 0)
- array[i - 1] += 1;
- }
- }
- bool hook = false;
- for (int i = 0; i < n; i++){
- if (array[i] != arrayofelem[count - 1])
- hook = true;
- }
- if (hook == true){
- hook = false;
- for (int i = 0; i < n - 1; i++){
- if (array[i] == 1 && array[i + 1] == 1 && array[i + 1] == 1)
- hook = true;
- }
- if (hook == false){
- for (int i = 0; i < n; i++)
- printf("%d", array[i]);
- printf("\n");
- }
- perestanovka();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment