• 2022-06-08
    有以下程序: #include <iostream> #include <cmath> using namespace std; class Distance; class point { public: friend class Distance; Point(int a,int B) { x=a; Y=b; } void Print() { cout<<"X= "<<X<<end1; cout<<"Y= "<<Y<<end1; } private: float X,Y; }; class Distance { public: float Dis(Point &p,Point &q); }; float Distance :: Dis(Point &p,Point &q) { float result; result=sqrt((p.X-q.X)*(p.X-q.X)+(p.Y-q.Y)*(p.Y-q.Y)); cout<<result<<end1; retUrn result; } int main() { Point p(10,10),q(10,30); Distance d; d.Dis(p,q); return 0; } 运行后的输出结果是( )。
    A: 10
    B: 30
    C: 0
    D: 20
  • D

    举一反三

    内容

    • 0

      有以下程序 void f(int *x,int *y) { int t; t=*x;*x=*y;*y=t; } main() { int a[8]={1,2,3,4,5,6,7,8},i,*p,*q; p=a;q=&a[7]; while(*p!=*q){f(p,q);p++;q--;} for(i=0;i<8;i++) printf("%d,",a[i]); } 程序运行后的输出结果是______。

    • 1

      已知 Point类,要求在该类中完成+,- 两种操作符的重载。(重写Point类)class Point{ public: Point(float x=0, float y=0, float z=0): xx(x), yy(y), zz(z){} Point(const Point&amp; p): xx(p.xx), yy(p.yy), zz(p.zz){ } private: float xx, yy, zz;}……

    • 2

      下列代码中: class Point{ int x,y; public: Point(int a, int b=0); //① Point(Point &aPoint); //②Point(Point *p); //③ 默认的构造函数是 A: ① B: ② C: ③ D: 没有

    • 3

      写出下列程序的运行结果。 #include<iostream. h> class X{ public: virtual void disp(){cout<<”X类的disp函数<<”end1;} }; class Y:public X{ public: void disp(){cout<<”Y类的disp函数<<”end1;} }; void main(){ X a, *p=&a; Y b; p->disp(); p=&b; p->disp(); } 运行结果为: &#91;14&#93; &#91;15&#93;

    • 4

      把 "x ( P( x )®$ y Q( x ,y ))化为前束范式,推导过程正确吗? "x ( P( x )®$y Q( x ,y )) Û"x (¬ P( x ) ∨ $y Q( x ,y )) Û"x$y (¬ P( x ) ∨ Q( x ,y )) Û" x $y ( P( x ) ®Q ( x ,y ))