2011年12月29日 星期四

九九乘法


請由"in.txt"中讀取一整數N(1<=N<=9),利用迴圈配合條件指令,印出九九乘法表的前N列至"out.txt"。
※請注意垂直對齊

7 則留言:

  1. Private Sub Form_Load()
    Me.Hide
    Open App.Path & "\in.txt" For Input As #1
    Open App.Path & "\out.txt" For Output As #2

    Input #1, x
    a = 1
    For i = 1 To x
    For y = 1 To i
    If i * y < 10 Then Print #2, " ";
    Print #2, i * y;
    Next
    Print #2,
    Next

    Close
    Close
    End
    End Sub

    回覆刪除
  2. 剛剛的A= 1 沒有刪除到 所以重貼一次!

    Private Sub Form_Load()
    Me.Hide
    Open App.Path & "\in.txt" For Input As #1
    Open App.Path & "\out.txt" For Output As #2

    Input #1, x
    For i = 1 To x
    For y = 1 To i
    If i * y < 10 Then Print #2, " ";
    Print #2, i * y;
    Next
    Print #2,
    Next

    Close
    Close
    End
    End Sub

    回覆刪除
  3. 作者已經移除這則留言。

    回覆刪除
  4. Private Sub Form_Load()
    Me.Hide
    Open App.Path & "\in.txt" For Input As #1
    Open App.Path & "\out.txt" For Output As #2
    Input #1, n
    For y = 1 To n
    For x = 1 To y
    If x * y < 10 Then Print #2, " ";
    Print #2, x * y;
    Next x
    Print #2,
    Next y
    Close #2
    Close #1
    End
    End Sub

    回覆刪除
  5. Private Sub Form_Load()
    Open App.Path & "/in.txt " For Input As #1
    Open App.Path & "/out.txt" For Output As #2
    Input #1, x
    For i = 1 To x
    For j = 1 To i
    If i * j < 10 Then Print #2, " ";
    Print #2, i * j;
    Next j
    Print #2,
    Next i
    Close
    Close
    End
    End Sub

    回覆刪除
  6. 小冰,晟晟,哲好,
    這樣的迴圈訓練,很好。


    11
    121
    1331
    14641
    這樣的更有數學功力的排列呢?
    試試吧。

    回覆刪除
  7. Private Sub Form_Load()
    Me.Hide
    Open App.Path & "/in.txt " For Input As #1
    Open App.Path & "/out.txt" For Output As #2
    Input #1, x
    For i = 1 To x
    For j = 1 To i
    If i * j < 10 Then Print #2, " ";
    Print #2, i * j;
    Next j
    Print #2,
    Next i
    Close
    Close
    End
    End Sub

    回覆刪除