C++问题,请问如何修改才能通过编译器
//TheRealBinaryTreeOfMine.cpp:定义控制台应用程序的入口点。//#include"stdafx.h"#include<string>#incl...
// TheRealBinaryTreeOfMine.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<string>
#include<stack>
#include<iostream>
using namespace std;
typedef struct BinaryTree{
char date;
struct BinaryTree * leftchild;
struct BinaryTree * rightchild;
BinaryTree(){
leftchild = NULL;
rightchild = NULL;
date = 0;
}
BinaryTree(char date){
date = this->date;
leftchild = NULL;
rightchild = NULL;
}
}BT;
void Build_BinaryTree(BinaryTree*& BT, string str){
stack <BinaryTree> s;
int i = str.size() - 1;
char ch=str[i-1];
while (ch != '\0')
{
if (ch != '\0' && ch >= '0' && ch <= '9')
{
BT = new BinaryTree(ch);
s.push(ch);
ch = str[i - 1];
}
else
{
BT = new BinaryTree(ch);
if (!s.empty())
{
BT->leftchild = s.top();
s.pop();
}
if (!s.empty())
{
BT->rightchild = s.top();
s.pop();
}
s.push(ch);
ch = str[i - 1];
}
}
}
void first(BinaryTree *BT){
if (BT){
first(BT->leftchild);
first(BT->rightchild);
cout << BT->date;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
cout << "00000000" <<endl ;
BinaryTree * B;
string Exp;
cin >> Exp;
Build_BinaryTree(B,Exp);
first(B);
system("PAUSE");
return 0;
} 展开
//
#include "stdafx.h"
#include<string>
#include<stack>
#include<iostream>
using namespace std;
typedef struct BinaryTree{
char date;
struct BinaryTree * leftchild;
struct BinaryTree * rightchild;
BinaryTree(){
leftchild = NULL;
rightchild = NULL;
date = 0;
}
BinaryTree(char date){
date = this->date;
leftchild = NULL;
rightchild = NULL;
}
}BT;
void Build_BinaryTree(BinaryTree*& BT, string str){
stack <BinaryTree> s;
int i = str.size() - 1;
char ch=str[i-1];
while (ch != '\0')
{
if (ch != '\0' && ch >= '0' && ch <= '9')
{
BT = new BinaryTree(ch);
s.push(ch);
ch = str[i - 1];
}
else
{
BT = new BinaryTree(ch);
if (!s.empty())
{
BT->leftchild = s.top();
s.pop();
}
if (!s.empty())
{
BT->rightchild = s.top();
s.pop();
}
s.push(ch);
ch = str[i - 1];
}
}
}
void first(BinaryTree *BT){
if (BT){
first(BT->leftchild);
first(BT->rightchild);
cout << BT->date;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
cout << "00000000" <<endl ;
BinaryTree * B;
string Exp;
cin >> Exp;
Build_BinaryTree(B,Exp);
first(B);
system("PAUSE");
return 0;
} 展开
展开全部
// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<string>
#include<stack>
#include<iostream>
using namespace std;
typedef struct BinaryTree{
char date;
struct BinaryTree * leftchild;
struct BinaryTree * rightchild;
BinaryTree()
{
leftchild = NULL;
rightchild = NULL;
date = 0;
}
BinaryTree(char date)
{
date = this->date;
leftchild = NULL;
rightchild = NULL;
}
}BT;
void Build_BinaryTree(BinaryTree*& BT, string str)
{
stack <BinaryTree> s;
int i = str.size() - 1;
char ch=str[i-1];
while (ch != '\0')
{
if (ch != '\0' && ch >= '0' && ch <= '9')
{
BT = new BinaryTree(ch);
s.push(ch);
ch = str[i - 1];
}
else
{
BT = new BinaryTree(ch);
if (!s.empty())
{
BT->leftchild = &s.top();
s.pop();
}
if (!s.empty())
{
BT->rightchild = &s.top();
s.pop();
}
s.push(ch);
ch = str[i - 1];
}
}
}
void first(BinaryTree *BT)
{
if (BT)
{
first(BT->leftchild);
first(BT->rightchild);
cout << BT->date;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
cout << "00000000" <<endl ;
BinaryTree * B;
string Exp;
cin >> Exp;
Build_BinaryTree(B,Exp);
first(B);
system("PAUSE");
return 0;
}
我的修改仅仅是能让你的代码编译成功
//
#include "stdafx.h"
#include<string>
#include<stack>
#include<iostream>
using namespace std;
typedef struct BinaryTree{
char date;
struct BinaryTree * leftchild;
struct BinaryTree * rightchild;
BinaryTree()
{
leftchild = NULL;
rightchild = NULL;
date = 0;
}
BinaryTree(char date)
{
date = this->date;
leftchild = NULL;
rightchild = NULL;
}
}BT;
void Build_BinaryTree(BinaryTree*& BT, string str)
{
stack <BinaryTree> s;
int i = str.size() - 1;
char ch=str[i-1];
while (ch != '\0')
{
if (ch != '\0' && ch >= '0' && ch <= '9')
{
BT = new BinaryTree(ch);
s.push(ch);
ch = str[i - 1];
}
else
{
BT = new BinaryTree(ch);
if (!s.empty())
{
BT->leftchild = &s.top();
s.pop();
}
if (!s.empty())
{
BT->rightchild = &s.top();
s.pop();
}
s.push(ch);
ch = str[i - 1];
}
}
}
void first(BinaryTree *BT)
{
if (BT)
{
first(BT->leftchild);
first(BT->rightchild);
cout << BT->date;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
cout << "00000000" <<endl ;
BinaryTree * B;
string Exp;
cin >> Exp;
Build_BinaryTree(B,Exp);
first(B);
system("PAUSE");
return 0;
}
我的修改仅仅是能让你的代码编译成功
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询