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

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

(考試時間: 13:10-13:20)


  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).
    #include <iostream>
    using std::cout;
    using std::endl;
    void swap(int, int);

    int main()
    {
    int a=10, b=20;
    swap(a, b);
    cout << a << "\t" << b << endl;
    }

    void swap(int x, int y)
    {
    int temp;
    temp = x;
    x = y;
    y = temp;
    cout << x << "\t" << y << endl;
    }

  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).
    #include <iostream>
    using std::cout;
    using std::endl;
    void cycle(int*, int*, int*);

    int main()
    {
    int a=10, b=20, c=30;
    cycle(&a, &b, &c);
    cout << a << "\t" << b << "\t" << c << endl;
    }

    void cycle(int* x, int* y, int* z)
    {
    int temp;
    temp = *x;
    *x = *y;
    *y = *z;
    *z = temp;
    cout << *x << "\t" << *y << "\t" << *z << endl;
    }