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

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

(考試時間: 10:30-10:45)

  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).
    N=10
    DIM A(N)
    FOR I=1 to N
    FOR J=I TO INT(N/I)*I STEP I
    A(J) = 1 - A(J)
    NEXT J
    NEXT I
    SUM=0
    FOR I=1 to N
    PRINT A(I); " ";
    SUM = SUM + A(I)
    NEXT I
    PRINT
    PRINT SUM
    END
  2. (10%) After running the following program, what will be the contents of the file "T:\MyFile2.txt"?

    FN$="T:\MyFile.txt"
    OPEN FN$ for OUTPUT AS #1
    FOR I = 1 to 5
      READ NAME$
      PRINT #1, NAME$
    NEXT I
    CLOSE #1
    DATA "Alice", "Bob", "Charlie", "Dennis", "Emily"

    DIM N$(5)
    OPEN FN$ for INPUT AS #2
    FOR I = 1 to 5
      INPUT #2, N$(I)
    NEXT I
    CLOSE #2

    OPEN "T:\MyFile2.txt" for OUTPUT as #3
    FOR I = 5 TO 1 STEP -1
      PRINT #3, N$(I)
    NEXT I
    CLOSE #3

    PRINT "Successful!"
    END