Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n, a[35];
  6. for(int i = 0; i < 35; i++) {
  7. a[i] = 1;
  8. }
  9. while(n < 1 || n > 35) {
  10. cin >> n;
  11. }
  12. int tmp = n - 1;
  13. while (a[0] != 0) {
  14. for(int i = 0; i < n; i++)
  15. {
  16. if((i == n - 1) || (a[i + 1] == 0)) {
  17. cout << a[i] << endl;
  18. break;
  19. }
  20. else cout << a[i] << "+";
  21. }
  22. if(a[tmp] - 1 >= a[tmp - 1] + 1 && tmp >= 1) {
  23. a[tmp]--, a[tmp - 1]++;
  24. }
  25. else {
  26. a[tmp - 1] += a[tmp];
  27. a[tmp--] = 0;
  28. }
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement