要用字符变量,但是读入时只读入两位数的一位怎么解决??
#include<iostream>
int sum = 0;
using namespace std;
struct BiNode {
int data;
BiNode* lchild, * rchild;
};
classBiTree
{
public:
BiTree() { root = creat(root); }
~BiTree();
void inOrder() { inOrder(root); }
private:
BiNode* root;
private:
BiNode* creat(BiNode* bt);
void inOrder(BiNode* bt);
};
BiNode* BiTree::creat(BiNode* bt) {
char ch;
ch = getchar();
if (ch == ',')
ch = getchar();
if (ch == '#')
bt = NULL;
else
{
bt = new BiNode;
bt->data =ch;这个地方读入时只读入两位数的一位怎么解决?输入数据是这样的:3,9,#,#,20,15,#,#,7,#,#
bt->lchild = creat(bt->lchild);
bt->rchild = creat(bt->rchild);
}
return bt;
} 没明白你的意思0-0
页:
[1]