|
发表于 2015-12-16 22:16:16
|
显示全部楼层
钢铁侠2014 发表于 2015-12-14 10:46
9 }: l0 B9 |4 a& ~- I* S很有意思的小题目啊,刚好最近在学python,晚上回家写个小程序算算
9 l3 M4 s4 ~5 Z9 C# b我的程序丑爆了。。。matlab
! x d* `9 g. }0 Tclear all
/ G$ Y' j' {: ^! C( Na=(10:99)';, E+ O) A+ T, q5 T
b=10:99;
' Z6 w; Q. `7 Ek=1;
1 x: O8 x0 f4 [& ]; Vc={};1 K3 H. f% O% v6 N& \
for i=1:90
" w$ H! [% E: k- v) K* X h for j=1:906 m6 W# X! Z# [$ h$ {$ X9 x; o
if a(i)<b(j)
; `6 p# n6 s" t0 E# n" D: O if floor(a(i)/10)==floor(b(j)/10)- a+ ~: u0 S" R }( f( x# T
if a(i)/b(j)==(a(i)-10*floor(a(i)/10))/(b(j)-floor(b(j)/10)*10)$ Q% u" r; o3 Z0 X' W& C% C M% m
c{k}=[a(i);b(j)];9 \$ e- y1 n; `9 z! U8 z6 S
k=k+1;
1 b+ `( e) F+ e2 E/ W% ? end; v, m, R# ^( L; R/ q9 d
end/ U. y/ c4 d0 l3 C$ r& z, {
end
+ R I) U* `5 w4 |" K4 @5 {: | end
$ {% K% R1 U# t: H" |% O! `end3 g7 }, O* K2 Z- v( F0 o
for i=1:90
1 ], S: m2 p( J for j=1:90
# |( L# m% [' p. R" j if a(i)<b(j)
% U1 c. _/ ~0 F if (a(i)-floor(a(i)/10)*10)==floor(b(j)/10)
4 m2 G7 @" u* Z2 y2 D6 v if a(i)/b(j)==floor(a(i)/10)/(b(j)-floor(b(j)/10)*10) W4 _# z! J- e. \8 X8 p
c{k}=[a(i);b(j)];" S- ]# X+ M" u* @
k=k+1;2 e9 {& u4 q+ K
end( l& {( j( k5 j) h& o. c
end
$ H' [) R+ G8 i+ ?3 x end4 y: S# M. n6 G$ B" a5 n
end- V! u4 m9 S' s4 k! M
end
1 ?5 h. ?4 l, g/ M/ C' F N% Cfor i=1:90$ z! ]* v: _9 @% |$ Z
for j=1:90
1 H, S1 n2 c6 f7 j( F7 @/ n; k/ @ if a(i)<b(j)
8 b w! i- i. e0 [. v if floor(a(i)/10)==(b(j)-floor(b(j)/10)*10)0 X' G- j+ N3 c6 b z! T
if a(i)/b(j)==(a(i)-10*floor(a(i)/10))/(floor(b(j)/10))
1 X3 ?/ k- { ?9 e7 z4 i c{k}=[a(i);b(j)];1 @. I- N( ~- r7 B
k=k+1;5 S7 b$ F: k3 N7 u
end
% @/ c2 e: |/ t% R end! O8 d ?: A F: y% y
end. @ a0 D) ^ r% V5 y5 d% M2 z- ] V
end
4 P8 m& f) H x5 k/ O: M0 k- cend% B D: {4 O$ K% ^1 Q% s0 Q9 E" K! [
for i=1:901 F& K$ @, M/ n" ^. @
for j=1:90
9 u! X5 Q ^. Y- k if a(i)<b(j)
! N& J; J9 k9 ^+ |( d1 b if (a(i)-floor(a(i)/10)*10)==(b(j)-floor(b(j)/10)*10); C% h8 j' ?$ E2 e% k
if a(i)/b(j)==(floor(a(i)/10))/(floor(b(j)/10))
+ r+ E7 a) U! M+ \$ q c{k}=[a(i);b(j)];4 X5 {9 W4 z2 M4 C- e1 q7 R
k=k+1;. k& \* M! w! k/ c
end
" ] M% {' D* M) s end
4 ]8 q( ^' r+ l* p- ] end
8 p4 l! U0 @; e1 e) ?4 T2 |( C9 R8 \ end6 V. L) q, F9 D& [+ C/ f+ l9 V& }
end; l2 G$ H7 B# U
$ q* P. h; Q; z# b. }' ~& \& ]" n[16;64]2 L& J& d- v h3 S1 a0 E' G7 o
[19;95]9 ~. L/ I' [5 l$ n- Q& y( z. p
[26;65]
* k4 }% T) s. B% H' Y[49;98]
2 D6 a b+ o) w) D! f6 N
+ c, H1 ?4 Z- N' Y8 ?" I- x
# ?' t, }! }2 ?2 f2 q9 C |
|