Redigi due programmi che generino le due figure sottostanti a sinistra. Quindi redigine due che generino le altre due.
0000000000 0 0000000000 0000000 0 0 00 0000000000 000000 0 0 0 0 0000000000 00000 0 0 0 0 0000000000 0000 0 0 0 0 0000000000 000 0000000000 000000 0000000000 00 0 |
Ecco come generare le figure con R:
source("http://macosa.dima.unige.it/r.R") HF=1.5; BF=1.5 BOXW(0,11,0,11) # o: boxmN(...) box monometrico con Nessuna (Without) griglia x <- 1:10; text(x,10,"O"); text(x,5,"O") y <- 10:5; text(1,y,"O"); text(10,y,"O") # per vedere la griglia posso introdurre: BOX() # BOXW(0,11,0,11) y <- 10:5; text(1,y,"O") x <- 1:6; text(x,5,"O"); text(x,11-x,"O") # BOXW(0,11,0,11) x <- 1:10; for(y in 10:5) text(x,y,"O") # BOXW(0,11,0,11) for(x in 1:7) for(y in x:7) text(x,y,"O") # # Ovvero: HF=2.2; BF=2.2; PLANEww(0,11,0,11) # o: PIANOss(0,11,0,11)
Ecco i programmi, redatti in QBasic e in JavaScript ( "calcolatore 2" neGli Oggetti Matematici):
for i=1 to 6 : for j=1 to 10 if j=1 or j=10 or i=1 or i=6 then print "0"; else print " "; next print : next for i=1 to 6 : for j=1 to i if j=1 or j=i or i=1 or i=6 then print "0"; else print " "; next print : next for i=1 to 6 : for j=1 to 10 print "0"; next print : next for i=1 to 7 : for j=1 to 8-i print "0"; next print : next
<pre><script> for (i=1; i<=6; i=i+1) { for (j=1; j<=10; j=j+1) { if (i==1 || j==1 || j==10 || i==6) document.write('0') else document.write(' ')} document.writeln('') } </script></pre> <script> for (i=1; i<=6; i=i+1) { for (j=1; j<=i; j=j+1) { if (i==1 || j==1 || j==i || i==6) document.write('0') else document.write(' ')} document.writeln('') } </script></pre> <pre><script> for (i=1; i<=6; i=i+1) { for (j=1; j<=10; j=j+1) document.write('0'); document.writeln('')}; </script></pre> <pre><script> for (i=1; i<=7; i=i+1) { for (j=1; j<=7-i+1; j=j+1) document.write('0'); document.writeln('') } </script></pre>
Figure simili possono essere costruite facilmente anche con WolframAlpha. vedi.