?? main.c
字號:
#include <stdio.h>#include <stdlib.h>typedef struct tree{ int n; struct tree *l; struct tree *r;}tree;tree a[8]; int s=1; void bl(tree* h);int main(){ int i; tree *h1; h1=&a[1]; for( i=1;i<4;i++) { a[i].l=&a[2*i]; a[i].r=&a[2*i+1]; a[i].n=i; } for(i=4;i<8;i++) { a[i].l=NULL; a[i].r=NULL; a[i].n=i; } bl(h1); system("pause"); return 0;}void bl(tree *h){ tree* l[20]; tree** p; tree** pp; tree *t=h;//頭節點標識 int m[20]; int *q; int i; q=&m[1]; p=&l[1];//printf("%d",m[19]); for (i=0;i<20;i++){ l[i]=0;m[i]=0;} *p=t;//頭節點標識 *q=1; while(p!=&l[0]){ while(t!=NULL){ p++;//l位進1 q++; (*q)=1; (*p)=t->l; t=t->l; } p--;q--; pp=p-1; if(p!=&l[0]&&(*q)==1){ (*q)++; p++; q++; (*p)=(*pp)->r; t=(*p); } if(p!=&l[0]&&*q==2){ printf("%d",(*p)->n); *q=0; t=NULL; } } /**/}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -