ParanoidPanda

Untitled

Dec 24th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. const int n = 5;
  5. const int count = 4;
  6. int counter = 0;
  7. int arrayofelem[count] = { 0, 1, 2, 3 };
  8. int array[n];
  9.  
  10. void perestanovka();
  11.  
  12. int main(){
  13. perestanovka();
  14. return 0;
  15. }
  16.  
  17. void perestanovka(){
  18. array[n - 1] += 1;
  19. for (int i = n - 1; i >= 0; i--) {
  20. if (array[i] > arrayofelem[count - 1]){
  21. array[i] = arrayofelem[0];
  22. if (i > 0)
  23. array[i - 1] += 1;
  24. }
  25. }
  26. bool hook = false;
  27. for (int i = 0; i < n; i++){
  28. if (array[i] != arrayofelem[count - 1])
  29. hook = true;
  30. }
  31. if (hook == true){
  32. hook = false;
  33. for (int i = 0; i < n - 1; i++){
  34. if (array[i] == 1 && array[i + 1] == 1 && array[i + 1] == 1)
  35. hook = true;
  36. }
  37. if (hook == false){
  38. for (int i = 0; i < n; i++)
  39. printf("%d", array[i]);
  40. printf("\n");
  41. }
  42. perestanovka();
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment