• 2022-10-29
    下面类的索引定义或使用正确的是()。
    A: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; }}}
    B: class MyClass{ int x; int y; public int this[int index] { set{ if (index==0) x=value; else y=value; }}}
    C: class MyClass{ int x; int y; public int INDEX[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}}
    D: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}}
  • D

    内容

    • 0

      有下列程序,程序运行后的输出结果是( )。 #include int fun (int x,int y); int main() { int a=4,b=5,c=6; printf("%d",fun(2*a,fun(b,c))); return 0; } int fun (int x,int y) { if (x!=y) return ((x+y)/2); else return (x); }

    • 1

      如果要实现计算x绝对值的功能,下面程序有错误的是? A: int fun(int x){ if(x<0) return -x;<br> return x; } B: int fun(int x){ if(x<0) return -x;<br> else return x; } C: int fun(int x){ if(x<0) return -x;<br> if(x>0) return x; } D: int fun(int x){ if(x<0) return -x;<br> else if(x==0) return x; else return x; }

    • 2

      下列类的定义中,正确的是() A: class a{int x=0;int y=1;}; B: class b{int x;int y=:1;}; C: class c{int x;int y;}; D: class d{int x=0,int y=1;};

    • 3

      ,d); return 0; } int dif(int x,int y,int z) { int max(int x,int y,int z); int min(int x

    • 4

      下面正确的是() #include <stdio.h> int main() { int max(int x,int y); int a,b,c; scanf("%d,%d",&a,&b); c=max(a,b); printf("max=%d ",c); return 0; } int max(intx,inty); { int z; if(x>y)z=x; else z=y; return(z); }