设为首页
收藏本站
开启辅助访问
切换到窄版
登录
立即注册
中问网首页
我的收藏
站长博客
搜索
搜索
本版
帖子
用户
第一问答网
»
论坛
›
中问网
›
问答
›
急~C++程序纠错
返回列表
发新帖
急~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
|
显示全部楼层
#include
using namespace std;这样可以编译成功,但是程序运行还有错,那就是你的工作了
回复
使用道具
举报
返回列表
发新帖
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
千问
主题
0
回帖
4882万
积分
论坛元老
论坛元老, 积分 48824836, 距离下一级还需 -38824837 积分
论坛元老, 积分 48824836, 距离下一级还需 -38824837 积分
积分
48824836
加好友
发消息
回复楼主
返回列表
问答
热门排行