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 qq = "十一二三四五六七八九十十一十二" yn = "元一二三四五六七八九十十一十二" y = InStr(x, "年") m = InStr(x, "月") d = InStr(x, "日") ayear = Mid(x, 3, y - 2 - 1) amonth = Mid(x, y + 1, m - y - 1) aday = Mid(x, m + 1, d - m - 1) If ayear >= 1911 Then Print #2, "民國"; Else Print #2, "民國前"; End If p = 1 Do Until p > Len(Abs(ayear - 1911)) step = Mid(Abs(ayear - 1911), p, 1) Print #2, Mid(yn, step + 1, 1); p = p + 1 Loop Print #2, "年"; If Val(amonth) < 11 Then Print #2, Mid(qq, amonth + 1, 1); Else Print #2, Mid(qq, amonth + 1, 2); End If Print #2, "月"; Select Case aday Case Is < 11 Print #2, Mid(qq, aday + 1, 1); Case 11 To 19 step = Right(aday, 1) Print #2, Mid(qq, 1, 1); Print #2, Mid(qq, step + 1, 1); Case 21 To 29 step = Right(aday, 1) Print #2, Mid(qq, 3, 1); Print #2, Mid(qq, step + 1, 1); Case 30 Print #2, Mid(qq, 4, 1); Print #2, Mid(qq, 1, 1); Case 20 Print #2, Mid(qq, 2, 1); Print #2, Mid(qq, 1, 1); Case 31 Print #2, Mid(qq, 4, 1); Print #2, Mid(qq, 1, 1); Print #2, Mid(qq, 2, 1); End Select Print #2, "日" Close #1 Close #2 End Sub
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
qq = "十一二三四五六七八九十十一十二"
yn = "元一二三四五六七八九十十一十二"
y = InStr(x, "年")
m = InStr(x, "月")
d = InStr(x, "日")
ayear = Mid(x, 3, y - 2 - 1)
amonth = Mid(x, y + 1, m - y - 1)
aday = Mid(x, m + 1, d - m - 1)
If ayear >= 1911 Then
Print #2, "民國";
Else
Print #2, "民國前";
End If
p = 1
Do Until p > Len(Abs(ayear - 1911))
step = Mid(Abs(ayear - 1911), p, 1)
Print #2, Mid(yn, step + 1, 1);
p = p + 1
Loop
Print #2, "年";
If Val(amonth) < 11 Then
Print #2, Mid(qq, amonth + 1, 1);
Else
Print #2, Mid(qq, amonth + 1, 2);
End If
Print #2, "月";
Select Case aday
Case Is < 11
Print #2, Mid(qq, aday + 1, 1);
Case 11 To 19
step = Right(aday, 1)
Print #2, Mid(qq, 1, 1);
Print #2, Mid(qq, step + 1, 1);
Case 21 To 29
step = Right(aday, 1)
Print #2, Mid(qq, 3, 1);
Print #2, Mid(qq, step + 1, 1);
Case 30
Print #2, Mid(qq, 4, 1);
Print #2, Mid(qq, 1, 1);
Case 20
Print #2, Mid(qq, 2, 1);
Print #2, Mid(qq, 1, 1);
Case 31
Print #2, Mid(qq, 4, 1);
Print #2, Mid(qq, 1, 1);
Print #2, Mid(qq, 2, 1);
End Select
Print #2, "日"
Close #1
Close #2
End Sub
網誌管理員已經移除這則留言。
回覆刪除Y揚好,
回覆刪除像這樣的題目,就是一個煩。不過呢,當比賽的時候出現這樣的題目,要小心的是「花時間」。
先將比賽的題目都「粗看」一次,了解一下,先從容易做的先做之後。
像這題,如果一時沒有好方法,土法練鋼,也是可以的啦。
反正「幾乎」將所有的可能都寫出來,慢慢換也是可以的。
(啊,說實話,這樣的題目,也沒很想法去「精進」地寫程式吧?)
(還是現在的我,懶懶的呢?)