Job Recruitment Website - Job seeking and recruitment - Using C language to realize permutation and combination (one of the interview questions of Huawei software)
Using C language to realize permutation and combination (one of the interview questions of Huawei software)
/Leave nX = m*n-x from the remaining nM baskets; Ball
int get ball (int NX, int nm, int n) {int na; int nS = ;
/* If it is determined that the ball is empty from a basket in this case *///If nM is equal to 1, return 1; if (nX < = n) {
/* Take it from at least one basket, and at most take it from a few baskets among nM and n */
// When nA increases from 1 to nX, execute the following statement ns+= getball (na, 1, n)+getball (NX-na, nm-1, n) circularly;
// returnS ns; } else if (nX > N) {
/* 1. Know the number of remaining baskets nM, 2. Ensure NX-na <; = nm * n */
/When nA decreases from n to nX-n*nM, the following statement NS+= getball (na, 1, n)+getball (NX-na, nm-1, n) is executed circularly;
// returnS ns; }
}
int main() { int m,n,x; m = 5; n = 6; x = 22; printf("%d\n",GetBall(m*n-x, m, n)); return ;
}
- Related articles
- Does Ole in Wangfujing, Lintong sell aj black and white panda shoes?
- Why did you lose your resume?
- Is Hefei Biohan a liar?
- When will the 2018 Zhaotong City Public Institutions Category D Recruitment Examination Interview Announcement be released? What is the format of the interview?
- Salary of Gaobu Town Central Primary School, Yuecheng District, Shaoxing City, Zhejiang Province
- How about graphic design? Is it a promising career?
- How about Humen Xingke Electronic Cigarette Comprehensive Department?
- When will the primary school in Liangxi District of Wuxi resume classes in April?
- Where can I post job information for free?
- Is Sacred Heart Pet Hospital Ruipeng's?