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
Joe Wilson
NA
7.8k
437.1k
Help me to rewrite my code below in C++?
Sep 26 2014 8:18 AM
I mean I want to use cout and cin instead of printf and scanf by the way I want to ask user to choose the members(numbers) of set and the size of set then use my printsubset function.
This is my code:
#include < stdio.h>
#include < conio.h>
#define MAX 20
int set[MAX];
int flag[MAX];
void printsubset(int n)
{
int i;
printf("{");
for (i=0 ; i < n ; i++)
if (flag[i])
printf ("%d ",set[i]);
printf("}\n");
}
void subset(int n,int i)
{
if (i==n)
{
printsubset(n);
return;
}
flag[i]=1;
subset(n,i+1);
flag[i]=0;
subset(n,i+1);
}
main()
{
int n=4;
for (int i=0 ; i < n ; i++)
{
set[i]=i+1;
flag[i]=0;
}
subset(n,0);
getch();
}
Reply
Answers (
1
)
Graph from layout table user input
Get value of each attribute in paricular object