/**
author : coder_zhang
time : 2014-6-14
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100
#define ARRAY_SIZE(array, type) (sizeof(array) / sizeof(type))
typedef struct node {
int value;
struct node* left;
struct node* right;
} node;
void pre_order(node* root) {
node* stack[MAX];
int pos = -1;
while (root != NULL || pos != -1) {
if (root == NULL) {
root = stack[pos--];
}
fprintf(stderr, "%c ", root->value);
if (root->right != NULL) {
stack[++pos] = root->right;
}
root = root->left;
}
fprintf(stderr, "
");
}
int index_char(const char* str, char ch) {
int pos = 0;
while (*str != '