• 2022-06-08
    运行如下程序,结果为_____。#include <;iostream>;using namespace std;int main( ){int x =10; do { cout <;<; --x ; }while( !x ); return 0;}
  • 9

    内容

    • 0

      有如下程序: #include<iostream> using namespace std; class XX{ int x; public: XX(int XX=0):x(xx){} int getX(){return x;} }; class YY:public XX{ int y; public: YY(int xx,int yy):XX(xx),y(yy){} int getV(){return getX()+y;} }; int main(){ YY c(3,4); cout<<c.getV()+c.getX()<<endl; return 0; } 运行这个程序的输出结果是______。 A: 3 B: 4 C: 7 D: 10

    • 1

      在下列选项中,没有构成死循环的程序段是______。 A: B: include <;iostream>;using namespace std;void main( ){ int i=2020; while(1) { i=i%100+1;if(i>;100)break; }} C: D: include <;iostream>;using namespace std;void main( ){ for(;;);} E: F: include <;iostream>;using namespace std;void main( ){ int i=36; while(i); --i;} G: H: include <;iostream>;using namespace std;void main( ){int i =10000;do{ ++i;}while(i>;=1000);}

    • 2

      中国大学MOOC: 下面程序输出结果为:#include<iostream>using namespace std;#include<string.h>int main( ){ char st[20]="hello\0\t\\"; cout<<strlen(st); cout<<sizeof(st)<<endl; cout<<st; return 0;}

    • 3

      以下程序执行后的输出结果是 #include <iostream> using namespace std; void try(int,int,int,int); int main () int x,y,z,r; x =1 ; y = 2; try(x,y,z,r); cout<<r<<endl; return 0; void try(int x,int y,int z,int r) z = x+y; x = x*x; y = y*y; r = z+x+y; A: 18 B: 9 C: 10 D: 不确定

    • 4

      阅读下列程序,写出运行结果。 #include &#91;iostream&#93; using namespace std; int main() { int a = 1, b = 2; bool x, y; cout &#91;< (a++)+(++b) << endl; cout << a % b << endl; x = !a&#93;b; y = a-- && b; cout << x << endl; cout << y << endl; }