國立暨南國際大學 96 學年度第二學期小考試卷

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

(考試時間: 09:40-10:00)

  1. (10%) Determine whether the following code is correct or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    // Ex7_01A.cpp
    #include <iostream>
    #include <windows.h>

    int main()
    {
    RECT aRect = { 0, 0, 100, 100 };
    RECT* pRect = &aRect;

    pRect.top += 10;

    std::cout << pRect.top;
    }
  2. (10%) Determine whether the following code is correct or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    // Ex7_01B.cpp
    #include <iostream>
    #include <windows.h>

    struct ListElement
    {
    int value;
    ListElement* pNext;
    }

    int main()
    {
    ListElement L1 = { 1 };
    L1.pNext = NULL;
    std::cout << L1.value << std::endl;
    }



  3. (10%) Determine whether the following code is correct or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    // Ex7_01C.cpp
    #include <iostream>
    #include <windows.h>

    struct ListElement
    {
    int value;
    ListElement* pNext;
    };

    int main()
    {
    ListElement L1 = { 1 };
    ListElement L2 = { 2 };
    ListElement L3 = { 3 };
    L1.pNext = &L2;
    L2.pNext = &L3;
    L3.pNext = NULL;
    ListElement* p = &L1;
    while (p != NULL)
    {
    std::cout << p->value << std::endl;
    p = p->pNext;
    }
    }