[Js]Ordinamento di un vettore

Come da nome.

[Js]Ordinamento di un vettore

Postby Krystal on Wed Jul 30, 2008 12:34 am

Code: Select all
<html>
<head>
</head>
   <body>
   <script language= "javascript">
   var i,m,j,scambia
   var vettore = new Array()

   for (i=0; i<=9; i++)
   {
   vettore[i]=parseInt(prompt("Inserisci valore "+i))
   }

   for (i=0; i<=8; i++)
        {
      for (j=i+1; j<=9; j++)
      {
         if (vettore[i]>vettore[j])
         {
         scambia = vettore[i]
         vettore[i] = vettore[j]
              vettore[j]=scambia
         }
      }
        }

   for (i=0; i<=9; i++)
   {
   alert("elemento n."+i+"  "+vettore[i])
   }
     
   </script>
   </body>   
</html>     
Krystal
Moderatore
 
Posts: 13
Joined: Wed Jul 05, 2006 10:04 pm

[Js]Ordinamento di un vettore

Sponsor

Sponsor


Return to (X)Html - Css -Javascript - Ajax -Flash

Who is online

Users browsing this forum: No registered users and 1 guest