摘要:
在编程中常会碰到,在某一个集合中,选集合中的几个数据进行计算。决定写个类似伪代码的代码,方便日后编程。int index=0;保存结果的集合;void fun(集合,集合长度,要选取的长度){ if(集合长度 < 要选取的长度) return ; if(要选取的长度<=0) {自己想要实现的功能模块} for(int i=0;i<集合长度;i++) { 保存结果的集合[index++]=集合[i]; fun(集合+i+1,集合长度-i-1,要选取的长度-1); index--; }} 阅读全文
posted @ 2013-05-02 11:24
浪浪辛
阅读(183)
评论(0)
推荐(0)
摘要:
1 #include<stdio.h> 2 #include<conio.h> 3 int fun(int m,int n) 4 { 5 if(m==n)return 1; 6 if(n==1)return m; 7 return fun(m-1,n)+fun(m-1,n-1); 8 } 9 int main()10 {11 printf("%d\n",fun(7,3));12 getch();13 return 0;14 } 阅读全文
posted @ 2013-05-02 11:04
浪浪辛
阅读(234)
评论(0)
推荐(0)
摘要:
1 #include<stdio.h> 2 #include<conio.h> 3 int result[100]; 4 5 void split(int n, int k, int c) 6 { 7 if (k == 0) return; 8 if (n == k) 9 {10 result[c]=k;11 for (int i = 0; i <=c; i++)12 printf("%d ",result[i]);13 printf("\n"); 14 if (k == 1)... 阅读全文
posted @ 2013-05-02 11:01
浪浪辛
阅读(194)
评论(0)
推荐(0)
摘要:
1 #include<stdio.h> 2 #include<conio.h> 3 char pStr[20]="abcd"; 4 void swap(char *a,char *b) 5 { 6 char temp = *a; 7 *a = *b; 8 *b = temp; 9 }10 void comp(char *pBegin)11 {12 if(!*pBegin)puts(pStr);13 char *p=pBegin;14 for(;*p;p++)15 {16 swap(p,pBegin);17 ... 阅读全文
posted @ 2013-05-02 10:58
浪浪辛
阅读(230)
评论(0)
推荐(0)
摘要:
1 #include<stdio.h> 2 #include<string.h> 3 4 char s[50]; 5 int index=0; 6 void reSort(char *pArray, int remainNum, int printLen) 7 { 8 if (remainNum < printLen)return; 9 if (printLen <= 0)10 {11 for(int i=0;i<index;i++)12 putchar(s[i]);13 putchar('\n');14 ... 阅读全文
posted @ 2013-05-02 10:55
浪浪辛
阅读(209)
评论(0)
推荐(0)

浙公网安备 33010602011771号