主题:05、06年合肥市赛编程题
QBfire
[专家分:50] 发布于 2009-03-14 09:30:00
1、5的100次方是一个很大的数,计算机无法直接计算出来,请编程求该式的准确结果。要求从最高位到最低位每一位都要打印出来,并将结果输入到数据文件BCH.DAT中。
2、若一个M*N的矩阵中的某一项A(I,J)是第I行中的最小值,也是第J列中的最大值,则称A(I,J)为一个鞍点。编程求出一个矩阵的鞍点。A(M,N)由键盘输入。若无,输出 “NO”。
如:A(2,3)
1 2 3
4 5 6
鞍点为第二行第一列的元素值4。
3、小华的妈妈在单位发放工资。每次也都努力使每个职工领到的人民币总张数最少。小华打算帮助妈妈编写程序,输入某位职工的工资数,则统计并输出应发给该职工面值100元、50元、20元、10元、2元、1元、5角、2角、1角、5分、2分、1分的人民币各多少张,使总张数最少。请帮助小华编出这首题目。
如:输入为256.58,则输出为:100:2;50:1;20:0;10:0;5:1; 2:0;1:1;0.5:1;0.2:0;0.1:0;0.05:1;0.02:1;0.01:1。
4、楼梯问题:爬楼梯时,一步可以爬一级楼梯,也可以一步爬两级楼梯,问爬20级楼梯有多少种不同的方法。如果爬1500级有多少种方法呢?也许数值太大,要用高精度算法。(台阶数N由键盘输入,N不大于1500,且已知当N不大于1500时,输出结果小于400位。)
如:输入台阶数100时,输出有:53147844013817084101种方法。
回复列表 (共2个回复)
沙发
hxy_anhui [专家分:320] 发布于 2009-03-14 20:34:00
1.
CLS
N = 5: M = 100: B$ = "1"
DIM A(1000), B(1000), C(1000)
FOR K = 1 TO M
A$ = LTRIM$(STR$(N)): LB = LEN(B$): LA = LEN(A$): LC = LA + LB
FOR I = 1 TO LA: A(I) = VAL(MID$(A$, LA + 1 - I, 1)): NEXT I
FOR I = 1 TO LB: B(I) = VAL(MID$(B$, LB + 1 - I, 1)): NEXT I: B$ = ""
FOR I = 1 TO LA: FOR J = 1 TO LB
W = I + J - 1: X = A(I) * B(J)
C(W) = C(W) + X MOD 10
C(W + 1) = C(W + 1) + X \ 10 + C(W) \ 10
C(W) = C(W) MOD 10
NEXT J, I
WHILE C(LC) = 0: LC = LC - 1: WEND
FOR I = LC TO 1 STEP -1: B$ = B$ + LTRIM$(STR$(C(I))): NEXT I
FOR I = LC TO 1 STEP -1: C(I) = 0: NEXT I
NEXT K: PRINT B$
END
2.
CLS
INPUT M, N
DIM A(M, N)
FOR I = 1 TO M: FOR J = 1 TO N: INPUT A(I, J): NEXT J, I: CLS
FOR I = 1 TO M: FOR J = 1 TO N
PRINT USING "###"; A(I, J);
NEXT J: PRINT : NEXT I
FOR I = 1 TO M
MIN = A(I, 1): H = 1
FOR J = 1 TO N
IF A(I, J) <= MIN THEN MIN = A(I, J): H = J
NEXT J: Q = 0
FOR K = 1 TO M
IF A(K, H) > MIN THEN Q = 1: GOTO 10
NEXT K
IF F = 0 THEN PRINT "I="; I, "J="; H, "AN DIAN:"; MIN
10 NEXT I
END
3.
CLS
INPUT N
N = N + .001
DIM A(13), B$(13)
FOR I = 1 TO 13: READ B$(I): NEXT I
DATA 100,50,20,10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01
FOR I = 1 TO 13
1 IF N >= VAL(B$(I)) THEN
N = N - VAL(B$(I)): A(I) = A(I) + 1
IF N >= 0 THEN 1
END IF
NEXT I
FOR I = 1 TO 13
PRINT B$(I), A(I)
NEXT I
END
4.
CLS
INPUT N
DIM A(255), B(255), C(255), A$(N)
A$(1) = "1": A$(2) = "2"
FOR K = 3 TO N
A$ = A$(K - 2): B$ = A$(K - 1): LA = LEN(A$): LB = LEN(B$): LC = LA + 1
REDIM A(LC),B(LC),C(LC)
FOR I = 1 TO LA: A(I) = VAL(MID$(A$, LA + 1 - I, 1)): NEXT I
FOR I = 1 TO LB: B(I) = VAL(MID$(B$, LB + 1 - I, 1)): NEXT I: G = 0
FOR I = 1 TO LC
X = A(I) + B(I) + G
C(I) = X MOD 10
G = X \ 10
NEXT I
IF G <> 0 THEN C(LC) = G
WHILE C(LC) = 0 AND LC > 1: LC = LC - 1: WEND: D$ = ""
FOR I = LC TO 1 STEP -1: A$(K) = A$(K) + LTRIM$(STR$(C(I))): NEXT I
NEXT K
PRINT A$(N)
END
板凳
chen_jin_111 [专家分:0] 发布于 2009-03-17 19:28:00
cls
input m,n
dim a(m,n)
for i=1 to m '输入阵列
for j=1 to n
input a(i,j)
next j
next i
for i=1 to m '输出阵列
for j=1 to n
print a(i,j);
next i
next j
for i=1 to m
c=0:d=0
for j=1 to n-1
if a(i,j)<a(i,j+1) then c=i:d=j '列中找最小值的位置
next j
if p=m then
for k=1 to j
if a(i,j)>a(k,j) then p=p+1 '判断在列中是否为最大数
next k
end if
if p=j then print "鞍点",aIi,j) else p=0
p=0
next i
if p=0 then print "无鞍点"
end
呵呵,不太会,请多指教,以上程序为找鞍点的,只会这最简单的拉!呵呵
我来回复