Private Sub Form_Load() Open App.Path & "/in.txt" For Input As #1 Input #1, N Close #1 Open App.Path & "/out.txt" For Output As #2 For i = 1 To N Print #2, i; For j = 2 To i x = i * j If Len(x) = 1 Then Print #2, " "; x; Else Print #2, x; End If Next j Print #2, Next i Close #2 End Sub
Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Input #1, n Close #1 Open App.Path & "\out.txt" For Output As #2 For i = 1 To n Print #2, i; For j = 2 To i x = i * j If Len(x) = 1 Then Print #2, " "; x; Else Print #2, x; End If Next j Print #2, Next i
Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Input #1, ans Close #1 Open App.Path & "\out.txt" For Output As #1 For i = 1 To ans Print #1, i; For j = 2 To i If i * j < 10 Then Print #1, " "; End If Print #1, i * j; Next j Print #1, Next i Close #1 End Sub
Public Sub Form_Load() Dim ans As Long Dim an As String Open App.Path & "/out.txt" For Output As #2 Me.Hide For i = 1 To 9 For j = 1 To i If i * j < 10 Then Print #2, " " & i * j; Else Print #2, i * j; End If Next j Print #2, Next i Close #2 End End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "/in.txt" For Input As #1
Input #1, N
Close #1
Open App.Path & "/out.txt" For Output As #2
For i = 1 To N
Print #2, i;
For j = 2 To i
x = i * j
If Len(x) = 1 Then
Print #2, " "; x;
Else
Print #2, x;
End If
Next j
Print #2,
Next i
Close #2
End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Input #1, n
Close #1
Open App.Path & "\out.txt" For Output As #2
For i = 1 To n
Print #2, i;
For j = 2 To i
x = i * j
If Len(x) = 1 Then
Print #2, " "; x;
Else
Print #2, x;
End If
Next j
Print #2,
Next i
Close #2
End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Input #1, ans
Close #1
Open App.Path & "\out.txt" For Output As #1
For i = 1 To ans
Print #1, i;
For j = 2 To i
If i * j < 10 Then
Print #1, " ";
End If
Print #1, i * j;
Next j
Print #1,
Next i
Close #1
End Sub
高仔、阿瑋、Y揚好,
回覆刪除三個人的程式都OK,九九乘法是很基本的「轉圈」練習,似乎也是你們一年級上學期的考題吧?
二個還是用了字串的方式處理數字,危險了些。
y揚的方式比較好,參考一下吧。
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Input #1, x
Close #1
Open App.Path & "\out.txt" For Output As #2
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 #2
End Sub
皓好,
回覆刪除OK的。
網誌管理員已經移除這則留言。
回覆刪除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 Len(i * j) <> Len(X * j) Then
Print #2, " ";
Print #2, i * j;
Else
Print #2, i * j;
End If
Next j
Print #2,
Next i
Close #1
Close #2
End Sub
老師
剛剛沒看清楚題目,
現在這個是我改過的!
小白好,
回覆刪除歡迎參加試練的一個月。
檔案的讀寫,一回生兩回熟,還ok啦。
不過,雖然你寫的方式也會可以,還是寫成正常的
"\in.txt" 而不是 "/in.txt" 。
(其實,為什麼會兩個都可以代表目錄區隔,我也覺得奇怪,但是,前一個是正常的方式)
If Len(i * j) <> Len(X * j) Then
Print #2, " ";
Print #2, i * j;
Else
Print #2, i * j;
End If
這一段的程式,可以參考上面一個"皓"的程式的部分,會簡單些。
但是一樣正確就是了。
(前面有小小担心選手們用字串的方式處理數字,問過前一個指導老師後,已經沒有關係了,就用吧。)
當選手是個光榮,沒錯。但是,也是條漫漫長路,會有辛苦與低潮的時候哦,先為你(還有所有的人)加油,覺得不順的時候,想想最初的「心」,再回頭努力起。
Public Sub Form_Load()
回覆刪除Dim ans As Long
Dim an As String
Open App.Path & "/out.txt" For Output As #2
Me.Hide
For i = 1 To 9
For j = 1 To i
If i * j < 10 Then
Print #2, " " & i * j;
Else
Print #2, i * j;
End If
Next j
Print #2,
Next i
Close #2
End
End Sub
1分50秒