程式設計-手寫題 - 考試

By Lucy
at 2013-09-30T23:37
at 2013-09-30T23:37
Table of Contents
※ 引述《GLTY (小呆呆~)》之銘言:
: : 下列程式輸出為何?
: : CLS
: : S = 0
: : FOR K = 1 TO 10
: : FOR I = 0 TO (K - 1)
: : FOR J = 0 TO (K - 1)
: : IF I < > J THEN S = S + 1
: : NEXT J
: : NEXT I
: : NEXT K
: : PRINT S
: : END
: : [解答]
k=1, i=0~0 , j=0~0 最內圈跑 1x1 - (i==j的情形) 1
k=2, i=0~1 , j=0~1 2x2 - 2
k=3, i=0~2 , j=0~2 3x3 - 3
k=4, i=0~3 , j=0~3 4x4 - 4
..............................................
..............................................
..............................................
k=10, i=0~9 , j=0~9 10x10 - 10
Total = 1x1+2x2+3x3+4x4+5x5+6x6+7x7+8x8+9x9+10x10-(1+2+3+4+5+6+7+8+9+10)
= 385 - 55
= 330
應該是這樣!!!
--
: : 下列程式輸出為何?
: : CLS
: : S = 0
: : FOR K = 1 TO 10
: : FOR I = 0 TO (K - 1)
: : FOR J = 0 TO (K - 1)
: : IF I < > J THEN S = S + 1
: : NEXT J
: : NEXT I
: : NEXT K
: : PRINT S
: : END
: : [解答]
k=1, i=0~0 , j=0~0 最內圈跑 1x1 - (i==j的情形) 1
k=2, i=0~1 , j=0~1 2x2 - 2
k=3, i=0~2 , j=0~2 3x3 - 3
k=4, i=0~3 , j=0~3 4x4 - 4
..............................................
..............................................
..............................................
k=10, i=0~9 , j=0~9 10x10 - 10
Total = 1x1+2x2+3x3+4x4+5x5+6x6+7x7+8x8+9x9+10x10-(1+2+3+4+5+6+7+8+9+10)
= 385 - 55
= 330
應該是這樣!!!
--
Tags:
考試
All Comments

By Hamiltion
at 2013-10-01T10:57
at 2013-10-01T10:57

By Jack
at 2013-10-05T12:21
at 2013-10-05T12:21

By Charlotte
at 2013-10-08T23:08
at 2013-10-08T23:08

By Jack
at 2013-10-12T12:27
at 2013-10-12T12:27
Related Posts
法緒問題

By Caroline
at 2013-09-30T23:26
at 2013-09-30T23:26
警特三等體測(男生)

By Sierra Rose
at 2013-09-30T23:06
at 2013-09-30T23:06
關於正當防衛的打擊錯誤

By Heather
at 2013-09-30T22:52
at 2013-09-30T22:52
關於正當防衛的打擊錯誤

By Elvira
at 2013-09-30T21:58
at 2013-09-30T21:58
程式設計-手寫題

By Irma
at 2013-09-30T21:41
at 2013-09-30T21:41