高級Oracle DBA,善長Linux系統維運以及Oracle數據庫管理,開發,調優. 具有多年PL/SQL開發經驗.
分类: C/C++
2007-11-21 14:12:46
|
#include #include #include /* m 進制數據加 1 */ void calc_inc(int calc[],int max) { int i = 0; /* over[i] == max : 該位已達最高狀態 */ for (; calc[i] == max ; i++ ) { calc[i] =0 ; } calc[i] ++; } void put_buf(char *dest, int size, char *base, int calc[]) { int i; for (i=0; i } } #define BSIZE 30 /* *類似於 N 進制數據 * */ int gen_dict(char *base, int outsize) { int i ; int level = strlen(base); int calc[BSIZE] ; int overflag[BSIZE] ; /*just for test */ for (i=0; i overflag[i] = level -1 ; } int *overbit =& (calc[outsize]) ; /* 溢出位 */ char outbuf[BSIZE] ={0}; while (*overbit == 0) { put_buf(outbuf,outsize, base, calc); fprintf(stdout,"%s\n", outbuf); calc_inc(calc, level-1); } return (0); } int main(int argc, char *argv[]) { char *data1= "abcdefghijklmopqrsturvwxyz" ; char *data2= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *data3= "0123456789"; gen_dict(data3,4); exit(0); } |