下面程序的输出结果是【 】。
include <iostream.h>
include <math.h>
class point
{
double x;
double y;
public:
point(double a, double b)
{
x=a;
y=b;
}
friend double distance(point a, point b) ;
};
double distance(point a, point b)
{
return sqrt ((a. x-b.x) * (a. x-b.x)+ (a. y-b. y) * (a. y-b. y) );
}
void main()
{
point p1(1,2);
point p2(5,2);
cout<<distance(p1,p2)<<end1;
}
第1题:
以下程序的运行结果是______。
include<iostream.h>
include<math.h>
template<class T>
class TAdd//定义类模板TAdd,T为类型
{
Tx,y;
public:
TAdd (Ta,Tb) {x=a,y=b;) //构造函数
Tadd() { retum x+y;}//成员函数
};
void main( )
{
TAdd<int>A (5,6);
第2题:
下面程序的输出结果是【 】。
include<iostream.h>
int add(int a, int b);
void main()
{
extern int x, y;
cout<<add(x, y)<<end1;
}
int x(20),y(5);
int add(int a, int b)
{
int s=a+ b;
return s;
}
第3题:
10、下面程序执行后的输出结果是()。 #include <stdio.h> #define DOUBLE(r) r*r int main() { int x=1,y=2,t; t = DOUBLE(x+y); printf("%d",t); return 0; }
A.5
B.6
C.7
D.8
第4题:
有以下程序: #include<iostream> #include<math> using namespace std; class point { private: double x; double y; public: point(double a,double B) { x=a; y=b; } friend double distance (point a,point B) ;
A.1
B.5
C.4
D.6
第5题:
下面程序的输出结果是( )。#include<iostream.h>void main(){int x=-1,y=5,z;z=(x++<0)&& (y-->=0);cout<<x<<'\t'<<y<<'\t'<<z<<end1;}
A.-1 5 0
B.-1 4 1
C.0 4 1
D.0 4 0