Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

program Datos !Programado por Luis Angel Carmona Ontiveros, tremendo ídolo de ídolos implicit none integer tam, i, j, temp, opcion integer, allocatable, dimension(:) :: num print *,"Inserta la cantid

program Datos

        !Programado por Luis Angel Carmona Ontiveros, tremendo ídolo de ídolos


      implicit none
      integer tam, i, j, temp, opcion
      integer, allocatable, dimension(:) :: num


      print *,"Inserta la cantidad de numeros a usar"
      read(*, "(i2)") tam


      allocate (num(tam))



      do while (opcion /= 4)


      print *,"Ordenador:"
      print *,"1.- Ingresar valores"
      print *,"2.- Ordenar de Menor a Mayor"
      print *,"3.- Ordenar de Mayor a Menor"
      print *,"4.- Salir del programa"
      read(*, "(i1)") opcion


      select case (opcion)

      case(1)

               print *,"Ingrese los numeros:"
               do i=1,tam
               read(*, "(i3)") num(i)
               end do


      case(2)

               do i=1,tam
               do j=i+1,tam

               if(num(i)>num(j)) then
                        temp = num(i)
                        num(i) = num(j)
                        num(j) = temp
               endif

               end do
               end do

               print *,"Lista ordenada Menor a Mayor:"
               do i=1,tam
               print *, num(i)
               end do


      case(3)

               do i=1,tam
               do j=i+1,tam

               if(num(i)<num(j)) then
                       temp = num(i)
                       num(i) = num(j)
                       num(j) = temp
               endif

               end do
               end do

               print *,"Lista ordenada Mayor a Menor"
               do i=1,tam
               print *, num(i)
               end do

       end select

       end do


      deallocate(num)
      end program Datos

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.