i want a full code for finding different ways to climb the n-stair case problem that is each step is either 1 or 2 stairs.
Eg- a 3-stairs staircase can be climbed in 3 ways :1-1,1-2,2-1.

Using subset method can any one can help me out for this problem?

i want a full code

Sorry, you are not going to get it. We don't do people's homework for them.

Member Avatar for iamthwee

c++ but you get the idea:

#include <iostream>
#include <string>

using namespace std;

string steps_taken = "";

void steps(int n, string steps_taken) {
    if (n == 0) {
        cout << steps_taken << endl;
    }
    if (n >= 1) {
        steps(n - 1, steps_taken + "1");
    }
    if (n >= 2) {
        steps(n - 2, steps_taken + "2");
    }
}


int main()
{
    int number = 4;

    steps(number,"");


}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.