#include<iostream>
using namespace std;
#define MAX 20
typedef struct BiNode{
int data;
struct BiNode* lchild, * rchild;
}BiNode,*BiTree;
void CreatTree(BiTree& T) {
int ch; cin >> ch;
if (ch == -1) T = NULL;
else {
if(!(T=(BiTree)malloc(sizeof(BiNode))))
exit(-1);
T->data = ch;
CreatTree(T->lchild);
CreatTree(T->rchild);
}
}
void InOrderTranver(BiTree T,int Arry[]) {
for (int i = 0; i <7 ; i++) {
if (T) {
InOrderTranver(T->lchild,Arry);
Arry[i] = T->data;
InOrderTranver(T->rchild,Arry);
}
}
}
void Judge(BiTree T,int Arry[]) {
for (int i = 0; i <7 ; i++) {
if (Arry[i] > Arry[i + 1])
cout << "no";
break;
}
cout << "yes";
}
void main() {
BiTree T;
CreatTree(T);
int Arry[8];
InOrderTranver(T,Arry);
Judge(T,Arry);
}
|