Nitish
BAN USER
Comments (8)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
c++ code
int a=0,b=0,cnt=0,N;
void fn(int n,char ch) {
if(n==N) { cnt++; return; }
if(a!=2) { a++; fn(n+1,'a'); }
if(b!=1) {a=0; b++; fn(n+1,'b'); }
a=0; fn(n+1,'c');
}
int main() {
a=0;b=0;cnt=0;
cin>>N;
a++; fn(1,'a');
a=0; b++; fn(1,'b');
a=0; fn(1,'c');
cout<<cnt;
system("pause");
return 0;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Here is my tested code :-
}
- Nitish May 03, 2012