Diferència entre revisions de la pàgina «Solucio escacs php»

De wikiserver
Dreceres ràpides: navegació, cerca
(Es crea la pàgina amb «<source lang="php"> <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> …».)
 
 
(3 revisions intermèdies per 3 usuaris que no es mostren)
Línia 1: Línia 1:
 
<source lang="php">
 
<source lang="php">
<!DOCTYPE html>
+
 
    <html>  
+
<!DOCTYPE html>
    <head>  
+
<html>
  <title></title>
+
    <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
        <title>ESCACS</title>
  </head>
+
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <body>  
+
    </head>
  <h3>Chess Board using Nested For Loop</h3>
+
    <body>
  <table width="270px" cellspacing="0px" cellpadding="0px" border="1px">
+
        <h3> TABLERO DE AJEDREZ DINÁMICO </h3>
  <!-- cell 270px wide (9 columns x 60px) --> 
+
        <table width="270px" cellspacing="0px" cellpadding="0px" border="1">
      <?php
+
        <?php
      for($row=1;$row<=9;$row++)
+
            for($x=0; $x<9;$x++){
      {
+
                echo "<tr>";
          echo "<tr>";
+
                for($i=0; $i<9;$i++){
          for($col=1;$col<=9;$col++)
+
                    /* Si es impar = 1 True por tanto blanco, primera casilla = 0 */
          {
+
                    if(($x+$i)%2){
          $total=$row+$col; 
+
                        echo "<td height='30px' width='30px' bgcolor='black'></td>";
          if($total%2==0)
+
                    }
          {
+
                    else{
          echo "<td height=30px width=30px bgcolor=#FFFFFF></td>";
+
                        echo "<td height='30px' width='30px' bgcolor='white'></td>";
          }
+
                    }
          else
+
                }
          {
+
                echo "</tr>";
          echo "<td height=30px width=30px bgcolor=#000000></td>";
+
            }
          }
+
       
          }
+
        ?>
          echo "</tr>";
+
        </table>
    }
+
    </body>
          ?>
+
</html>
  </table>
+
</source>
  </body>
+
 
  </html>
+
<?php
</html>   
+
 
<source>
+
for ($i=0; $i <8 ; $i++) {
 +
 +
for ($j=0; $j <8 ; $j++) {
 +
if($j%2==0) {
 +
echo "  *  ";
 +
}else{
 +
echo "  * ";
 +
}
 +
}
 +
echo "<br>";
 +
}
 +
 
 +
?>

Revisió de 18:20, 6 oct 2023

<!DOCTYPE html>
<html>
    <head>
        <title>ESCACS</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h3> TABLERO DE AJEDREZ DINÁMICO </h3>
        <table width="270px" cellspacing="0px" cellpadding="0px" border="1">
        <?php
            for($x=0; $x<9;$x++){
                echo "<tr>";
                for($i=0; $i<9;$i++){
                    /* Si es impar = 1 True por tanto blanco, primera casilla = 0 */
                    if(($x+$i)%2){
                        echo "<td height='30px' width='30px' bgcolor='black'></td>";
                    }
                    else{
                        echo "<td height='30px' width='30px' bgcolor='white'></td>";
                    }
                }
                echo "</tr>";
            }
        
        ?>
        </table>
    </body>
</html>

<?php

for ($i=0; $i <8 ; $i++) {

for ($j=0; $j <8 ; $j++) { if($j%2==0) { echo " * "; }else{ echo " * "; } } echo "
"; }

?>