• 2021-04-14
    #分析下面程序运行的结果。
    #include
    usingnamespacestd;
    intmain
    {
    cout<<"This"<<"is";
    cout<<"a"<<"C++";
    cout<<"program."<return0;
    }#
  • ThisisaC++program.

    内容

    • 0

      中国大学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;}

    • 1

      【填空题】下列程序的输出结果是________。#include<iostream>usingnamespacestd;intf(inta,intb){staticintx=3;if(b>2){x=x*x;b=x;}elseb=x+1;returna+b;}intmain(){inta=3,b;b=2;cout<<f(a,b)<<endl;b=3;cout<<f(a,b);return0;}

    • 2

      下列程序的输出结果是_____。#includeusingnamespacestd;templateTfun(Ta,Tb){return(a<=b)?a:b;}intmain(){cout<<fun(3,6)<<','<<fun(3.14F,6.28F)<<endl;return0;}

    • 3

      阅读下列程序,写出运行结果。 #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; }

    • 4

      阅读下面的程序, 请写出程序的输出结果 。 #include<iostream> using namespace std; int main () { enum Color {Red,Green,Blue}; Color color; color=Red; cout<<color<<","; color=Green; cout<<color<<","; color=Blue; cout<<color<<","; cout<<Red+Green+Blue<<endl; return 0; }