Jump to content
Fórum Script Brasil
  • 0

exercicio


kahalani

Question

5 answers to this question

Recommended Posts

  • 0

Antes de escrever o código, preste atenção na imagem...

Veja as diagonais em preto, por exemplo:

Todos os elementos da diagonal principal possuem ambas as coordenadas iguais (0,0 1,1 2,2 3,3 4,4 5,5 6,6 7,7 8,8 9,9)

Todos os elementos da diagonal secundária possuem coordenadas cuja soma é igual a 9 (0,9 1,8 2,7 3,6 4,5 5,4 6,3 7,2 8,1 9,0)

Há outras similaridades, pense bem.

Link to comment
Share on other sites

  • 0

então pessoal isso foi o que consegui fazer agora travou tudo rs

<?php

$x = "+";

$y = "-";

$col = 9;

$lin = 9;

echo "<table border='1'>";

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

echo "<tr>\n";

for($j=0; $j<$col; $j++){

echo $j;

if($i==$j){

$bgcolor="#000";

}else{

$bgcolor="#ccc";

}

if($i==4){

echo " <td bgcolor='".$bgcolor."' width='50' height='50' align='center' >".$x."</td>\n";

}else{

if($j==4){

echo " <td bgcolor='".$bgcolor."' width='50' height='50' align='center' >".$x."</td>\n";

}else{

echo " <td bgcolor='".$bgcolor."' width='50' height='50' align='center' >".$y."</td>\n";

}

}

}

echo "</tr>\n";

}

echo "</table>";

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...