简单的考试填空题!帮忙!多谢了!savior00(VC不是这样用地!)更是请进
简单的考试填空题!各位高手帮忙!谢谢了!急急急!savior00(VC不是这样用地!!)更是请进
由于时间太紧,没有检查~肯定有错的地方~但是因为是填空题~应该没什么问题吧~谢谢了~问题解决马上结贴!
savior00(VC不是这样用地!!)兄弟,刚才我那个帖子结贴时给错分了~你也回一个我给你补上~要是你还会下面两个题的话我更感谢你了!
第一题:
//一个整数数组类的说明,填空题
#include <iostream.h>
#include <stdib.h>
class Array{
int size, * buf;
public:
Array(int n=10){
size=n;
buf=new 需填空地方1;
for(int i = 0; i <size;i++)buf[i]=0;
}
~Arry(){ 需填空地方2 buf;}
int &operator[](int);//重载==运算符
};
int &Array::operator[](int i){
if(需填空地方3)}
{cout < < "下标越界\n ";exit(1);}
return buf[i];
}
int Array::operator == (const Array & r){
if(size 需填空地方4) return 0; //数组的大小不等
for(int i=0;i <size;i++)
if(需填空地方5) return 0; //对应数组元素不等
return 1; //数组相等
}
第二题:
//顺序栈的类模板的说明
#include <iosteam.h>
template <class TYPE>
class Stack{
intsize,top; TYPE * stackPtr;
public:
Stack(int s=10)
{
size=s> 0 && s <1000?s:10; top= -1;
stackPtr = new TYPE[size];
}
~Stack() {需填空地方1 stackPtr;}
int push(const TYPE & item)
{
if(需填空地方2 )//判栈满
{stackPtr[需填空地方3]=item; return 1;}
return 0;
}
int pop(TYPE &popValue)
{
if(需填空地方4)//判栈非空
{
popValue=stackptr[需填空地方5];return1;
}
}
};
------解决方案--------------------
第一题:
需填空地方1 int[n]
需填空地方2 delete []
需填空地方3 i > = size
需填空地方4 != r.size
需填空地方5 buf[i] != r.buf[i]
------解决方案--------------------
第一题:
需填空地方1 int[n]
需填空地方2 delete []
需填空地方3 i > = size
需填空地方4 != r.size
需填空地方5 buf[i] != r.buf[i]
第二题:
需填空地方1 delete []
需填空地方2 top==size-1
需填空地方3 top++
需填空地方4 top!=0
需填空地方5 top--
由于时间太紧,没有检查~肯定有错的地方~但是因为是填空题~应该没什么问题吧~谢谢了~问题解决马上结贴!
savior00(VC不是这样用地!!)兄弟,刚才我那个帖子结贴时给错分了~你也回一个我给你补上~要是你还会下面两个题的话我更感谢你了!
第一题:
//一个整数数组类的说明,填空题
#include <iostream.h>
#include <stdib.h>
class Array{
int size, * buf;
public:
Array(int n=10){
size=n;
buf=new 需填空地方1;
for(int i = 0; i <size;i++)buf[i]=0;
}
~Arry(){ 需填空地方2 buf;}
int &operator[](int);//重载==运算符
};
int &Array::operator[](int i){
if(需填空地方3)}
{cout < < "下标越界\n ";exit(1);}
return buf[i];
}
int Array::operator == (const Array & r){
if(size 需填空地方4) return 0; //数组的大小不等
for(int i=0;i <size;i++)
if(需填空地方5) return 0; //对应数组元素不等
return 1; //数组相等
}
第二题:
//顺序栈的类模板的说明
#include <iosteam.h>
template <class TYPE>
class Stack{
intsize,top; TYPE * stackPtr;
public:
Stack(int s=10)
{
size=s> 0 && s <1000?s:10; top= -1;
stackPtr = new TYPE[size];
}
~Stack() {需填空地方1 stackPtr;}
int push(const TYPE & item)
{
if(需填空地方2 )//判栈满
{stackPtr[需填空地方3]=item; return 1;}
return 0;
}
int pop(TYPE &popValue)
{
if(需填空地方4)//判栈非空
{
popValue=stackptr[需填空地方5];return1;
}
}
};
------解决方案--------------------
第一题:
需填空地方1 int[n]
需填空地方2 delete []
需填空地方3 i > = size
需填空地方4 != r.size
需填空地方5 buf[i] != r.buf[i]
------解决方案--------------------
第一题:
需填空地方1 int[n]
需填空地方2 delete []
需填空地方3 i > = size
需填空地方4 != r.size
需填空地方5 buf[i] != r.buf[i]
第二题:
需填空地方1 delete []
需填空地方2 top==size-1
需填空地方3 top++
需填空地方4 top!=0
需填空地方5 top--