|
阅读:2347回复:0
台阶问题。问题的描述见数据结构书。
首先申明俺的不咋地。望高手多多指教。
#include"stdio.h" char FootTrace[30]; void StepSearch(int StepLeft,char *CurrentFootTrace) { if( StepLeft==0 ){ *CurrentFootTrace = '\0'; printf("%s ",FootTrace); } if( StepLeft<=0 ) return; *CurrentFootTrace = '1'; StepSearch(StepLeft-1,CurrentFootTrace+1); *CurrentFootTrace = '2'; StepSearch(StepLeft-2,CurrentFootTrace+1); *CurrentFootTrace = '3'; StepSearch(StepLeft-3,CurrentFootTrace+1); } void main() { printf("\n\t\t\tProgram is running:\n"); StepSearch(6,FootTrace); printf("\n\t\tProgram is over,press any key to quit!"); } |
|