Diferència entre revisions de la pàgina «Solució Retrat Robot»
De wikiserver
Línia 1: | Línia 1: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
+ | |||
var desc = "1 9W;1 1|2 1o1 1o2 1|;1@4 1U4 1@;1 1|2 3=2 1|;2 1\\5_1/"; | var desc = "1 9W;1 1|2 1o1 1o2 1|;1@4 1U4 1@;1 1|2 3=2 1|;2 1\\5_1/"; | ||
− | var | + | |
− | + | var c = desc.split(";"); | |
− | for( | + | for (linea in c){ |
− | + | for(i = 0; i < c[linea].length; i = i + 2){ | |
− | + | ||
− | + | for (j = 0; j < parseInt(c[linea].charAt(i)); j++){ | |
− | + | caracter = c[linea].charAt(i+1); | |
− | + | if(caracter == " ") caracter = " "; | |
− | + | document.write(caracter); | |
− | + | } | |
− | + | } | |
− | + | document.write("<br>"); | |
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | ||
+ | |||
</source> | </source> |
Revisió de 20:27, 23 set 2015
var desc = "1 9W;1 1|2 1o1 1o2 1|;1@4 1U4 1@;1 1|2 3=2 1|;2 1\\5_1/";
var c = desc.split(";");
for (linea in c){
for(i = 0; i < c[linea].length; i = i + 2){
for (j = 0; j < parseInt(c[linea].charAt(i)); j++){
caracter = c[linea].charAt(i+1);
if(caracter == " ") caracter = " ";
document.write(caracter);
}
}
document.write("<br>");
}