急~C++程序纠错

[复制链接]
查看11 | 回复3 | 2010-5-11 22:23:45 | 显示全部楼层 |阅读模式
#include"iostream.h"
class node
{
friend class linkedstack;
int data;
node *next;
public:
node(int n)
{
data=n;
next=NULL;
}
};
class linkedstack
{
node *top;
public:
linkedstack()
{
top=NULL;
}
void push(int value);
void pop(int &value);
bool isempty();
};
void linkedstack::push(int value)
{
node *temp;
temp=new node(value);
temp->next=top;
}
void linkedstack::pop(int &value)
{
if(top=NULL)
coutdata;
top=top->next;
delete temp;}
}
bool linkedstack::isempty()
{
return top==NULL;
}
void conversion(int &n,int &m)
{
int x;
linkedstack *ls;
while(n)
{
ls->push(n%m);
n=n/m;
}
while(!ls->isempty())
{
ls->pop(x);
if(x>9)
cout>n;
cout>m;
cout<<"转换后结果";
conversion(n,m);
}

回复

使用道具 举报

千问 | 2010-5-11 22:23:45 | 显示全部楼层
给你改好了#include"iostream.h"class node{friend class linkedstack; int data; node *next;public: node(int n) {data=n;next=NULL; }};class linkedstack{ node *top;public: linkedstack() {top=NULL; }void push(int value);void pop(int &value);bool isempty();};void linkedstack::p
回复

使用道具 举报

千问 | 2010-5-11 22:23:45 | 显示全部楼层
#include//预编译自己看下吧using namespace std;class node{friend class linkedstack; int data; node *next;public: node(int n) {data=n;next=NULL; }};
回复

使用道具 举报

千问 | 2010-5-11 22:23:45 | 显示全部楼层
#includeusing namespace std;这样可以编译成功,但是程序运行还有错,那就是你的工作了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行