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> …».)
 
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++)
+
               
          {
+
                    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>
 
  </body>
 
  </html> 
 
</html>
 
 
<source>
 
<source>

Revisió del 15:45, 17 oct 2014

<source lang="php">

<!DOCTYPE html> <html>

   <head>
       <title>ESCACS</title>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   </head>
   <body>

TABLERO DE AJEDREZ DINÁMICO

<?php for($x=0; $x<9;$x++){ echo ""; for($i=0; $i<9;$i++){ if(($x+$i)%2){ echo "";
                   }
                   else{
echo "";
                   }
               }
echo ""; }  ?>
   </body>

</html> <source>