赞
踩
- #include<stdlib.h>
- #define N 100
-
- int flag[N];
-
- void print(int* flag){
- int i = 0;
- for(; i < N; i++){
- if(flag[i] == 1){
- printf("%d ",i+1);
- }
- }
- printf("\n");
- }
-
- void findSum(int m, int n, int* flag){
- if(n < 1 || m < 1){
- return;
- }
-
- if(m == n){
- flag[n - 1] = 1;
- print(flag);
- flag[n - 1] = 0;
- }
-
- flag[n - 1] = 1;
- findSum(m-n, n-1, flag );
-
- flag[n - 1] = 0;
- findSum(m, n-1, flag );
- }
-
- int main(){
- findSum(11, 10, flag);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。