TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ken H
NA
646
360.7k
Using a recursive parameter problem
Jan 12 2014 8:50 AM
hello,
My questions are as follows:
#include <iostream>
using namespace std;
inline void print(char a,char b){
cout<<a<<"->"<<b<<endl;
}
void test(int n,char c1,char c2,char c3){
if(n==1) print(c1,
c3
); // Here c3 is 'B'. Why is this so? c3 should be equal to 'C'.
else{
test(n-1,c1,
c3
,
c2
); // Note:Here c3 and c2 swapped positions.
print(c1,c3); // Here returned to normal.
}
}
int main(){
test(2,'A','B','C');
return 1;
}
Its results are:
A->B
A->C
I think the result should be:
A->C
A->C
Thank.
Reply
Answers (
1
)
Combinations number in c language
C++ Advice