國立暨南國際大學 100 學年度第一學期小考試卷

科目名稱:資訊系統 與網路導論 開課系所:資訊工程 學系 任課教師
吳坤熹
系所別:
年級:
學號:
姓名:
考試日期
2011.10.5

(考試時間: 14:15-14:35)

  1. (10%) What will the following code display?

    #include <iostream>       
    using std::cout;
    using std::endl;

    int main()
    {
        short a = 97;
        short mask = 0x20;
        a = a & (~mask);
        cout << a << '\t';
        a = a ^ mask;
        cout << a << endl;
        return 0;
    }


  2. (10%) What will the following code display?

    #include <iostream>       
    using std::cout;
    using std::endl;

    int main()
    {
        int a = 2;
        int b;
        b = --a = --a;
        cout << a << '\t' << b << endl;
        return 0;
    }


  3. (10%) What will the following code display?

    #include <iostream>       
    using std::cout;
    using std::endl;
    using std::cin;

    int main()
    {
        int n = 28;
        int odd = 0;
        int even = 0;
        switch (n % 2)
        {
        case 0:
            even++;
        case 1:        // The "break" statement is omitted.  What will happend?
            odd++;
        }
        cout << "even=" << even << endl;
        cout << "odd=" << odd << endl;
        return 0;
    }


  4. (10%) What will the following code display?

    #include <iostream>       
    using std::cout;
    using std::endl;
    using std::cin;

    int main()
    {
        short y = 1900;   
        bool leap = (y % 4 == 0) && ((y % 100 != 0) || (y% 400 == 0));
        cout << "There are "
            << (leap?366:365)
            << " days in Year " << y << endl;
        return 0;
    }