下面程序通过调用函数模板实现计算两个正整数的最大公约数,把main函数中的错误找出并改正过来。
#include
template
gcd(T x,T y)
{ while(x!=y)
{if(x >y)x-=y;
Else y - =x;
return x;
}
void main()
{int a;
double d;
cin>>a>>d;
cout<
}
有两个矩阵a和b,都是2行3列。求两个矩阵之和。重载运算符“+”,使之能用于矩阵相加。如=a+b。
给出下面程序输出结果。
#include
void main()
{int*p1;
Int**p2=&p1;
int b=20;
p1=&b;
cout<<**p2<
}
给出下面程序的输出结果。
#include< iostream.h>
template
class Complex
{T real,image;
public
Complex(T a, T b): real(a){ image=b;}
Complex(T a){image=0,real=a;}
void pr()
{char c;
c=(image>0'+':'-');
if (image!=0)
cout<
else
Cout<
}
};
void main()
{Complex
a.pr()
Complex
b.pr();
}
在下面横线处填上正确的内容,完成类的定义。
class Base
}
int x;
static const int b:
public:
Base(int,int);
const int &a;
};
___________b=15;
Base::Base(int i, int j):___________{}
计算1~20之间偶数之和。
#include
void main()
{int a,i;
a=0;
for(i=0;i<21;_________)
{
_________
}
cout<<"偶数之和为:"<
}
下面程序用来求直角三角形斜边长度。
#include
#include
class Point
{private:
double x,y;
__________
public:
Point(double i=0,double j=0)
{x=i,y=j}
Point(Point &p)
{x=p.x; y=p.y;}
};
class Line
{private:
Point p1,p2;
public:
Line(Point &xp1, Point &xp2):__________{}
double GetLength();
};
double Line: GetLength()
{double dx=p2.x-p1.x;
double dy=p2.y-p1.y;
return sqrt(dx*dx+dy*dy)
}
void main()
{Point p1, p2(6,8);
Line L1(p1,p2);
cout<
}
#include
class AA
{public:
AA()
{A=i;B=j;cout<<"Constructor\n";}
AA(AA &obj)
{A=obj.A;
B=obj.B;
cout<<"Copy Constructor\n";
}
~AA(){cout<<"Destructor\n";}
void show()
{cout<<"A="<
private:
int A,B:
};
void main()
{AA a1(2,3);
AA a2(a1);
a2.show();
_________= &a2;
pa->show();
}
下面程序实现数值、字符串的交换。
#include
#include
using namespace std;
template
void Swap(T&a,T&b)
{T temp;
temp=a;a=b;b=temp;
}
void main()
{int a=5,=9;
char s1[]="Hello",s2[]="hi";
Swap(a,b);
Swap(s1,s2);
cout<<"a="<
cout<<"s1="<
}
完成下面类中成员函数的定义。
#include
#include
using namespace std;
class str
{private:
char*st;
public:
str(char *a)
{set(a);}
str& perator=(_______)
{delete st;
set(a.st);
return*this;}
void show(){cout<
~str(){delete st;}
void set(char*)//初始化st
{________
strcpy(st,s);
}
};
void main()
{str s1("he"), s2("she");
S1.show(), s2.show()
s2=s1;
s1.show() ,s2.show();
}
#include
using namespace std;
void main(){
int x=32,y=37;
const int*p=&x;
*p=y;
cout<<*p<
}
2005年初级经济师考试《旅游经济专
初级旅游经济师试题及答案一
初级旅游经济师试题及答案二
2005年初级经济师考试《邮电经济专
初级经济师试题及答案1(邮电经济)
初级经济师试题及答案1(保险经济)
初级经济师试题及答案2(邮电经济)
初级经济师试题及答案2(保险经济)
初级经济师试题及答案3(保险经济)
2014年经济师初级考试真题《建筑经