iteration

//前序遍历
#include<stdio.h>
#define SIZE 8
char Tree[SIZE] = {0, 'A' ,'B','C','D','E','F','G'};

void preOrder(int root)
{
    if(root * 2 >= SIZE)
    {
        printf("%c",Tree[root]);
        return;
    }
    printf("%c",Tree[root]);
    preOrder(root * 2);
    preOrder(root * 2 + 1);
}


int main(void)
{
    preOrder(1);
    return 0;
}

 

posted @ 2017-04-01 15:34  xcsllll  阅读(116)  评论(0编辑  收藏  举报