t = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Clear[H]; H[t_, n_Integer] := Module[ {i = 0, b = t, n, a = 0}; For[i = 1, i <= n, i++, a = a + b[[i]]]; a ] H[t, 10] 代码。。。
t = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Clear[H]; H[t_, n_Integer] := Module[{i = 0, b = t, m = n, a = 0}, For[i = 1, i <= m, i++, a = a + b[[i]]]; a] H[t, 10]