Un problemita para los constructivos

Vyk2rr vyk2rr en gmail.com
Vie Feb 18 15:07:12 CLST 2005


Sopas!


On Fri, 18 Feb 2005 17:43:22 +0100, sagrario <sagrariot en telecable.es> wrote:
> El mié, 16-02-2005 a las 19:48, Vyk2rr escribió:
> > Quiero multiplicar dos matrices
> > de la forma que esta en esta imagen...
> >
> > http://www.geocities.com/vyk2rr/victor.jpg
> >
> > ... si corren el script se daran cuenta como.... pero no lo puedo realizar...
> > tengo problemas...
> >
> > haber quien me puede ayudar a resolver esto.. yo agradeceria mucho.
> >
> > //----------------------------------
> > <style>
> > table{font-size:40;}
> > </style>
> > <?
> > $filas=3;
> > $cols=3;
> >
> > echo"<table border=1><tr><td>&nbsp;</td><td>";
> > //---------------------
> > echo"<table border=1 cellspacing=0>";
> > for($c1=1;$c1<=$filas;$c1++){
> >          echo"<tr>";
> >              for($c2=1;$c2<=$cols;$c2++){
> >                      $matriz2[$c1][$c2]=rand(1,3);
> >                      echo"<td>".$matriz2[$c1][$c2]."</td>";
> >                  }
> >          echo"</tr>";
> >      }
> > echo"</table>";
> > //--------------------------
> > echo"</td></tr><tr><td>";
> > //---------------------------
> > echo"<table border=1 cellspacing=0>";
> > for($c1=1;$c1<=$filas;$c1++){
> >          echo"<tr>";
> >              for($c2=1;$c2<=$cols;$c2++){
> >                      $matriz1[$c1][$c2]=rand(1,2);
> >                      echo"<td>".$matriz1[$c1][$c2]."</td>";
> >                  }
> >          echo"</tr>";
> >      }
> > echo"</table>";
> > //------------------------------
> >
> > echo"</td><td>";
> > //*******
> >
> >
> >
> >
> > for($cc=1;$cc<=$filas;$cc++){
> >          for($ff=1;$ff<=$cols;$ff++){
> >
> >  $c1=$cc;
> >  for($c2=$ff;$c2<=$cols;$c2++){
> >          $mult=$matriz1[$c1][$c2]*$matriz2[$c2][$c1];
> >          //echo"<font style=\"font-size:11;\">[$c1,$c2]*[$c2,$c1],</font>";
> >          $suma=$suma+$mult;
> >          $mult=0;
> >      }
> > echo"<font color=Red>".$suma,", </font>";
> >                  //echo"$cc,$ff, ";
> >
> >          $suma=0;
> >
> >
> >
> >
> >
> >
> >              }
> >          echo"<br>";
> >      }
> > //**************
> >
> > //-----------------------------
> > echo"<table border=0 cellspacing=0>";
> > $c3=1;
> > for($c1=1;$c1<=$filas;$c1++){
> >          echo"<tr>";
> >              for($c2=1;$c2<=$cols;$c2++){
> >                      echo"<td>".$matriz3[$c1][$c2]."</td>";
> >                  }
> >          echo"</tr>";
> >          $c3++;
> >      }
> > echo"</table>";
> >
> > //----------------------------
> > echo"</td></tr></table>";
> >
> > ?>
> > //----------------------------------
> >
> 
> no se si es lo que quieres pero este mini script hace exactamente las
> sumas que hay en el enlace, tu verás si lo puedes adaptar a tus
> necesidades
> 
> <?php
> $uno=array("3","2","5");
> $dos=array("1","4","7");
> $suma=0;
> for ($i=0; $i < count($uno); $i++)
> {
> 
>         $result=($uno[$i]*$dos[$i]);
>         $suma=($result + $suma);
>         echo "$uno[$i] por $dos[$i] es igual a $result <br>";
>         echo "y la suma es $suma <br>";
> }
> ?>
> 
> 


-- 
www.algoritmia.info



Más información sobre la lista de distribución PHP