Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, a[35];
- for(int i = 0; i < 35; i++) {
- a[i] = 1;
- }
- while(n < 1 || n > 35) {
- cin >> n;
- }
- int tmp = n - 1;
- while (a[0] != 0) {
- for(int i = 0; i < n; i++)
- {
- if((i == n - 1) || (a[i + 1] == 0)) {
- cout << a[i] << endl;
- break;
- }
- else cout << a[i] << "+";
- }
- if(a[tmp] - 1 >= a[tmp - 1] + 1 && tmp >= 1) {
- a[tmp]--, a[tmp - 1]++;
- }
- else {
- a[tmp - 1] += a[tmp];
- a[tmp--] = 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement