函数check()用来判断字符串s是否是“回文”(顺读和倒读都一样的字符串称为“回文”,如abcba)。若是回文,函数返回值为1;否则返回值为0。请完成此函数的定义。
注意:部分源程序已存在考生文件夹的文件PROC7.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数check()的花括号中填写若干语句。
文件PROC7.cpp的内容如下:
//PROC7.cpp
include<iostream>
include<string>
using namespace std;
int check(char*s);
int main()
{
char str[100],*p;
cout<<"Input your string!";
cin>>str;
p=str;
cout<<"The result is:"<<check(p)<<end1;
}
int check(char*s)
{
// * * * * + * * *
}
第2题
下列程序的运行结果是______。
include<iostream.h>
class test
{
private:
int hum;
public:
test( );
int TEST( ){return num+100;)
~test( );
};
test::test( ){num=0;)
test::~test( ){cout<<"Destructor is active"<<endl;)
void main( )
{
test x[3];
cout<<x[1].TEST( )<<endl;
}
请帮忙给出正确答案和分析,谢谢!
第3题
在下面程序的画线处填上适当的内容,使程序执行后的输出结果为ABCD。
include <iostream>
using namespace std;
class A{
public:A( ){cout<<'A';}
};
class B: (11) {
public:B( ){cout<<'B';}
{;
class C: (12) {
public:C( ){cout<<'C';}
};
class D:public B,public C{
public:D( ){cout<<'D';}
};
void main( ){
D( );
cout<<endl;
}
请帮忙给出正确答案和分析,谢谢!
第4题
在下面程序的画线处填上适当的内容,使程序执行后的输出结果为1/2005。
include <iostream>
using namespace std;
class Date{
public:
Date(int m=1,int y=0):month(m),year(y){}
void Print( ){cout<<month<<"/"<<year<<endl;}
(9) operator+(const Date&dl,const Date& d2);
private:
int month,year;
};
(10) operator+(const Date& dl,const Date& d2){
int year,month;
year=d1.year+d2.year;
month=d1.month+d2.month;
year+=(month-1)/12;
month=(month-1)%12+1;
return Date(month,year);
}
void main( ){
Date dl(3,2004),d2,d3(10);
d2=d3+dl;
d2.Print( );
}
请帮忙给出正确答案和分析,谢谢!
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!