PONTIFICIA UNIVERSIDAD CATOLICA DEL ECUADOR
                                    SEDE IBARRA

NOMBRE: Espinosa Villarreal Héctor Efrén
NIVEL: Quinto de Ingeniería en Sistemas
FECHA: 09-04-2013
ASIGNATURA: Compiladores
TEMA: Como compilar de forma manual con Java

   1. Elaboramos nuestro programa (ordenamiento de números de forma ascendente) usando
      NetBeans 7.1
   2. Vamos al CMD (Inicio/Ejecutar/Cmd)
   3. Nos dirigimos a la ubicación donde se encuentra nuestro archivo .java
      (F:DocumentsPUCESIQUINTOCompiladoresTareasCompilar_Ordenarsrccompilar_o
      rdenar)
   4. Compilamos con la siguiente línea de código: javac Compilar_Ordenar.java y podemos
      verificar cuando nos crea el archivo Compilar_Ordenar.class
   5. Ejecutamos con la siguiente línea de código: java Compilar_Ordenar
   6. Listo; hemos compilado de manera manual nuestro programa
Código fuente de mi programa:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package compilar_ordenar;

importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;

/**
 *
 * @author HEESPINOSA
 */
public class Compilar_Ordenar {

   /**
    * @paramargs the command line arguments
    */
public static void main(String[] args) throws Exception {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Ingresenumero: ");
intnumero = Integer.parseInt(r.readLine());
int []x = new int[numero];
for (int i = 0; i <numero; i++) {
System.out.print("El valor de la posicion "+ i +" es: ");
x[i] = Integer.parseInt(r.readLine());
      }
intauxiliar;
if(numero%2==0){
for (int i = 0; i < (numero/2); i++) {
for (int j = i; j < (numero/2); j++) {
if(x[i]>x[j]){
auxiliar = x[i];
x[i]=x[j];
x[j]=auxiliar;
               }
           }
        }
for (int i = (numero/2); i <numero; i++) {
for (int j = i; j <numero; j++) {
if(x[i]<x[j]){
auxiliar = x[i];
x[i]=x[j];
x[j]=auxiliar;
               }
           }
}
      } else{
for (int i = 0; i <numero; i++) {
for (int j = i; j <numero; j++) {
if(x[i]>x[j]){
auxiliar = x[i];
x[i]=x[j];
x[j]=auxiliar;
               }
           }
         }
      }
for (int i = 0; i <numero; i++) {
System.out.print(x[i]+",");
}
   }
}

Compilar mediante dos

  • 1.
    PONTIFICIA UNIVERSIDAD CATOLICADEL ECUADOR SEDE IBARRA NOMBRE: Espinosa Villarreal Héctor Efrén NIVEL: Quinto de Ingeniería en Sistemas FECHA: 09-04-2013 ASIGNATURA: Compiladores TEMA: Como compilar de forma manual con Java 1. Elaboramos nuestro programa (ordenamiento de números de forma ascendente) usando NetBeans 7.1 2. Vamos al CMD (Inicio/Ejecutar/Cmd) 3. Nos dirigimos a la ubicación donde se encuentra nuestro archivo .java (F:DocumentsPUCESIQUINTOCompiladoresTareasCompilar_Ordenarsrccompilar_o rdenar) 4. Compilamos con la siguiente línea de código: javac Compilar_Ordenar.java y podemos verificar cuando nos crea el archivo Compilar_Ordenar.class 5. Ejecutamos con la siguiente línea de código: java Compilar_Ordenar 6. Listo; hemos compilado de manera manual nuestro programa
  • 3.
    Código fuente demi programa: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ //package compilar_ordenar; importjava.io.BufferedReader; importjava.io.IOException; importjava.io.InputStreamReader; /** * * @author HEESPINOSA */ public class Compilar_Ordenar { /** * @paramargs the command line arguments */ public static void main(String[] args) throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Ingresenumero: "); intnumero = Integer.parseInt(r.readLine()); int []x = new int[numero]; for (int i = 0; i <numero; i++) { System.out.print("El valor de la posicion "+ i +" es: "); x[i] = Integer.parseInt(r.readLine()); } intauxiliar; if(numero%2==0){ for (int i = 0; i < (numero/2); i++) { for (int j = i; j < (numero/2); j++) { if(x[i]>x[j]){ auxiliar = x[i]; x[i]=x[j]; x[j]=auxiliar; } } } for (int i = (numero/2); i <numero; i++) { for (int j = i; j <numero; j++) { if(x[i]<x[j]){ auxiliar = x[i]; x[i]=x[j]; x[j]=auxiliar; } }
  • 4.
    } } else{ for (int i = 0; i <numero; i++) { for (int j = i; j <numero; j++) { if(x[i]>x[j]){ auxiliar = x[i]; x[i]=x[j]; x[j]=auxiliar; } } } } for (int i = 0; i <numero; i++) { System.out.print(x[i]+","); } } }