cannot convert parameter 1 from 'int' to 'int &' 5
#include<iostream.h>#include<stdlib.h>#defineMAX20classsqstack{private:int*base;intto...
#include <iostream.h>
#include <stdlib.h>
#define MAX 20
class sqstack
{
private:
int *base;
int top;
int maxsize;
int x;
public:
sqstack();
~sqstack();
bool stackempty();
bool stackfull();
bool pushstack(int &x);
bool popstack(int &x);
bool gettop(int &x);
};
sqstack::sqstack()
{
base=new int[MAX];
if (!base) exit(-1);
top=-1;
maxsize=MAX;
}
bool sqstack::stackempty()
{
if (top==1)
return true;
else
return false;
}
bool sqstack::stackfull()
{
if (top==maxsize-1)
return true;
else
return false;
}
bool sqstack::pushstack(int &X)
{
if (top==maxsize-1)
return false;
else
{
top++;
base[top]=x;
return true;
}
}
bool sqstack::popstack(int &X)
{
if (top==-1)
return false;
else
{
x=base[top];
top--;
return true;
}
}
bool sqstack::gettop(int &X)
{
if (top==-1)
return false;
else
{
x=base[top--];
return true;
}
}
void conversion(int n)
{
sqstack s;
if (n==0)
{
cout<<0<<endl;
return;
}
while(n)
{
s.pushstack( n%8);
n=n/8;
}
cout<<"结果为:";
while (!s.stackempty())
{
s.popstack(n);
cout<<n;
}
cout<<endl;
}
void main()
{
int n;
cout<<"输入十进制数"<<endl;
cin>>n;
conversion(n);
} 展开
#include <stdlib.h>
#define MAX 20
class sqstack
{
private:
int *base;
int top;
int maxsize;
int x;
public:
sqstack();
~sqstack();
bool stackempty();
bool stackfull();
bool pushstack(int &x);
bool popstack(int &x);
bool gettop(int &x);
};
sqstack::sqstack()
{
base=new int[MAX];
if (!base) exit(-1);
top=-1;
maxsize=MAX;
}
bool sqstack::stackempty()
{
if (top==1)
return true;
else
return false;
}
bool sqstack::stackfull()
{
if (top==maxsize-1)
return true;
else
return false;
}
bool sqstack::pushstack(int &X)
{
if (top==maxsize-1)
return false;
else
{
top++;
base[top]=x;
return true;
}
}
bool sqstack::popstack(int &X)
{
if (top==-1)
return false;
else
{
x=base[top];
top--;
return true;
}
}
bool sqstack::gettop(int &X)
{
if (top==-1)
return false;
else
{
x=base[top--];
return true;
}
}
void conversion(int n)
{
sqstack s;
if (n==0)
{
cout<<0<<endl;
return;
}
while(n)
{
s.pushstack( n%8);
n=n/8;
}
cout<<"结果为:";
while (!s.stackempty())
{
s.popstack(n);
cout<<n;
}
cout<<endl;
}
void main()
{
int n;
cout<<"输入十进制数"<<endl;
cin>>n;
conversion(n);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询