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
361.7k
How to permutation and combination?
Oct 8 2012 10:15 PM
hi,
i have 8 digital,now I want to know a choice 5 combination how many kinds of.
Code fragment:
#include <cstdio>
void main()
{
int ResultNum[8]={1,8,9,10,11,14,17,20},i,j=0,k=0;
for (i=0;i<8;i++)
{
for (j=i+1;j<8;j++)
{
if(k<=5)
{
//
how to do?
printf("\n");
k++;
}
else if (k>=5) k=0;
}
}
}
Below is the result of simulation:
NO.1:
1,8,9,10,11
NO.2:
1,8,9,10,14
NO.3:
1,8,9,10,17
NO.4:
1,8,9,10,20
NO.5:
1,8,9,11,14
NO.6:
1,8,9,11,17
NO.7:
1,8,9,11,20
NO.8:
1,8,10,11,14
......
......
......
thanks.
Reply
Answers (
3
)
Advantages of inheritance in C++
Reference array char* in C