如果表达式--x中的“--”是重载的类运算符,采用运算符函数调用格式,该表达式还可以表示为【】。
如果表达式--x中的“--”是重载的类运算符,采用运算符函数调用格式,该表达式还可以表示为【 】。
如果表达式--x中的“--”是重载的类运算符,采用运算符函数调用格式,该表达式还可以表示为【 】。
第1题
以下程序的输出结果为【 】。
include<iostream>
using namespace std;
void initialize(int printNo,int state=0);
void initialize(int printNo=l,int state);
int main()
{
initialize();
return 0;
}
void initialize(int printNo,int state)
{
cout<<printNo<<","<<state<<end1;
}
第2题
以下程序执行时,输出“”号的个数是【 】。
include <iostream.h>
vied main(){
int i, j;
for(i=1;i<5;i++)
for(j=2;j<=i;j++)cout<<‘’;
}
第3题
回0,主函数中输出NO。回文是指顺读和倒读都一样的字符串。
例如:字符串LEVEL是回文,而字符串123312就不是回文。
注意;部分源程序已存在文件test26_.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test26_2.cpp的内容如下:
include<iostream.h>
include<stdio.h>
define N 80
int fun(char*str)
{
}
void main()
{char s[N];
cout<<"Enter a string:"<<endl;
gets{s);
cout<<"\n\n";
puts(s);
if(fun(s))
cout<<"YES\n";
else
cout<<"NO\n";
}
第4题
以下程序的执行结果是【 】。
include<iostream.h>
include<iomanip.h>
void pnnt(int n)
{
if (n!=0)
{
Print(n-1);
for (int i=1;i<=n;i++)
cout<<setw(3)<<i;
cout<<endl;
}
}
void main()
{
print(4);
}
第5题
以下程序的执行结果是【 】。
include<iostream.h>
void main()
{
int a=0,b=1,c=0,d=20;
if(a) d=d-10;
else if(!b)
if(!c) d=15;
else d=25;
cout <<"d="<<d<<endl;
}
第7题
下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。
define MAXSIZE 100
template <class T>
class Stack
{
T s[MAXSIZE];
int top;
public:
stack()
{
top=1;
}
void push(T newValue)
{
if(top<MAXSIZE)
{
top=top+1;
s[top]=newValue;
}
else
cout<<"堆栈满,无法进栈"<<end1;
}
void pop();
};
【 】
{
if(top>1)
{
cout<<s[top]<<end1;
top=top-1;
}
else
cout<<"堆栈空! "<<end1;
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!