假定一个类的构造函数为 “A(int aa=1, int bb=0) {a=aa; b=bb;}”,则执行 “A x(4);”语句后,x.a和x.b的值分别为()
请补充函数fun(),该函数的功能是把数组bb中的数按从小到大的排列(数组的值及元素个数从土函数中输入)。例如,输入2 3 5 4 1,结果为1 2 3 4 5。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()吧的横线上填入所编写的若干表达式或语句。试题程序:include<stdio. h>define N 100void fun(int bb[], int n){int i,j,t;for (i=0;【 】;i++)for(j=0;【 】;j++)if(bb[j]>bb[j+1] ){t=bb[j];bb [j]=bb [j+1];bb[j+1]=t;}}main(){int i=0, n=0;int bb[N];clrscr ();printf("\nInput n: \n");scanf ("%d", &n);printf ("\nInput data: \n");while (i<n){printf ("bb [%d] =", i);scanf ("%d", &bb [i]);i++;}fun (bb, n);printf("\n*** the result ***\n");for (i=0; i<n; i++ )printf ( "%4d'', bb [i]);}
点击查看答案
下列程序的运行结果是【】。include class A{ int a, b; public: A() {a=b=0;} A(int下列程序的运行结果是【 】。include <iostream. h>class A{int a, b;public:A() {a=b=0;}A(int aa, int bb){a=aa; b=bb;cout<<a<<''<<b<<end1;}};void main(){ A x, y(2,3),z(4,5); }
( 30 )有如下程序:#include<iostream>using namespace std;class AA{lilt k;protected:int n;void setK ( int k ) { this->k=k;}public:void setN ( int n ) { this->n=n;}};class BB: public }{/* 类体略 */};int main () {BB x_ ; //1x .n=1; //2x.setN ( 2 ) ; //3x.k=3; //4x .setK ( 4 ) ;return 0;}在标注号码的四条语句中正确的是A ) 1B ) 2C ) 3D ) 4
( 30 )有如下程序:#include<iostream>using namespace std;public:AA(){ cout<<'1'; }};class BB: public AA{int k;public:BB():k(0){ cout<<'2'; }BB(int n):k(n){ cout<<'3';}}int main(){BB b(4), c;return 0;}运行时的输出结果是A ) 1312B ) 132C ) 32D ) 1412
有如下函数定义;void func(int a,int & b){a++;b++;}若执行代码段:int x=0,y=1;func(x,y);则变量x和y的值分别是A.0和1B.1和1C.0和2D.1和2
下列程序中声明了两个类AA和BB,其中函数“print”是类AA的成员函数,但是类BB的友元函数。请在①、②和⑧处各填入正确的内容,使程序能正常运行。include<iostream.h>【 】;class AA{int t;public:AA(int x){t=x;}void print(BB &b) ;};class BB{int s;public:BB(int y){s=y;}friend void 【 】 print(BB &);};void 【 】{ cout<<"AA:"<<t<<"BB: "<<w.s<<end1;}<void main(){AA m(6);BB n(8);m.print(n);}输出结果为:AA:6;BB:8
函数定义如下: void fun(int x,int& y){x++;y++;} 如果执行代码段: int a=0,b=1; fun(a,b); 则变量a和b的值分别是( )。A.0和1B.0和2C. 1和1D.1和2