|
钢铁侠2014 发表于 2015-12-14 10:46
4 @9 M" e- @5 m$ w9 U8 |
很有意思的小题目啊,刚好最近在学python,晚上回家写个小程序算算
; E. n/ ^- A& {: l我的程序丑爆了。。。matlab/ G8 v2 ~, o! u# L clear all ]& }5 W/ e- M2 t+ Ra=(10:99)'; $ _5 h9 v4 o: X) N Fb=10:99;4 H: S1 T" Y$ v2 ` k=1; 3 b/ {- l5 {! G7 M7 ac={}; $ C8 N, t) ]6 g: W5 e: K+ Afor i=1:904 J" l: f! @8 R- i for j=1:903 P. ^5 w9 e2 ?# U# ]) y3 P if a(i)n( B$ h; @$ r2 U' j% q. iif floor(a(i)/10)==floor(b(j)/10) : I% ~# ]/ {8 qif a(i)/b(j)==(a(i)-10*floor(a(i)/10))/(b(j)-floor(b(j)/10)*10) , C) }2 c' u2 l5 q( `: r$ |6 Ic{k}=[a(i);b(j)];1 C% ^) u0 w9 E k=k+1;4 t2 h% G1 ~3 |. H& | end# z$ l o6 P, Z end : r& N/ C3 M' {7 f4 _1 W. Qend" ]+ ~; F8 \# Q9 G" u end 5 _; K0 i1 ]; Eend ( k6 B* w( m$ ?- _for i=1:90 : X8 `+ x* w: t6 J" @for j=1:90 & K9 P$ ~3 B7 B! k2 o4 b. B9 c( iif a(i)) t$ F9 f; L8 r$ hif (a(i)-floor(a(i)/10)*10)==floor(b(j)/10) 3 G+ M( W4 D7 X- v+ l/ x" B9 F0 I5 eif a(i)/b(j)==floor(a(i)/10)/(b(j)-floor(b(j)/10)*10)+ u" h5 b/ t5 \7 p) s; d" F p2 g' t c{k}=[a(i);b(j)];5 q4 G7 ]$ ]% W% c k=k+1;: p0 k6 Y9 c* R2 D+ N end 5 |1 ^! e' C+ xend- C8 N; ~2 w Q$ _1 _% |0 }3 K end% i) e6 U; _4 I b% d3 j; j end% Q. ^; g! ?: b- h4 o end # {/ ^$ I& F+ b* s( E" }for i=1:90x5 d* }* Z' ?0 ^8 f3 |% M( w for j=1:90 ! v; w' X o4 ~if a(i)' K( C+ }4 k1 B6 Q if floor(a(i)/10)==(b(j)-floor(b(j)/10)*10)0 F+ V3 ^- S* B8 [# G if a(i)/b(j)==(a(i)-10*floor(a(i)/10))/(floor(b(j)/10)) 5 U" ?7 u2 {% P! w- o Z1 i( wc{k}=[a(i);b(j)]; 9 J) U9 _, m5 [0 F1 Ik=k+1;6 H' U0 j7 Q; S end' L( q- W, i G3 K6 T7 C6 \ endw2 O$ Z2 z6 g4 g( S }$ f; R7 Z end* E+ `' D+ ^: X. E- I2 y end 3 ~9 y' m- o3 V2 E9 Hend: y+ q! `6 k6 }" ^ for i=1:90 0 L* W) \8 u0 F0 s7 d, @8 ^$ Ufor j=1:90 " q" Q7 y9 H7 A2 z% p# D! i0 tif a(i)% e2 o+ V1 W3 yif (a(i)-floor(a(i)/10)*10)==(b(j)-floor(b(j)/10)*10) ! o) r, \: w* K& x( Y Kif a(i)/b(j)==(floor(a(i)/10))/(floor(b(j)/10))+ f" D/ U: c" ~2 J c{k}=[a(i);b(j)];4 I: r3 y' o* Y# g- t% d k=k+1; . j7 l0 }9 e8 q. Jend ) p. K* j' \8 L7 K5 [end9 k5 M& P& F. r end6 |; {- ?1 d2 e+ o+ C! Y, b0 y' f ` end- g# c8 |1 H# W- h$ v; |6 | end* q. U) f( W: Y9 j& A$ A + X) Y- p' }- `+ C. `# ?- ~ [16;64] & K p9 T1 Y2 x/ n[19;95]3 k+ G: F+ f; }& ^ [26;65] 4 y0 {8 v! d5 O0 q[49;98] 8 E: o! {, U/ J0 e/ C - }7 V3 Z j# j( e9 h! z- n - }$ {# Y- J% }& x |
|