compilación con dos

4
PONTIFICIA UNIVERSIDAD CATÓLICA DEL ECUADOR SEDE IBARRA ESCUELA DE INGENIERIA CARRERA DE SISTEMAS NOMBRE: Grace Laguna FECHA: 09-04-2013 NIVEL: Quinto COMPILACIÓN CON DOS 1. Con la ayuda del cmd compilamos el programa. 2. Al ser compilado correctamente se crea un archivo .class

Upload: grace-laguna

Post on 06-Aug-2015

49 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Compilación con DOS

PONTIFICIA UNIVERSIDAD CATÓLICA DEL ECUADOR SEDE IBARRA ESCUELA DE INGENIERIA CARRERA DE SISTEMAS

NOMBRE: Grace Laguna FECHA: 09-04-2013

NIVEL: Quinto

COMPILACIÓN CON DOS

1. Con la ayuda del cmd compilamos el programa.

2. Al ser compilado correctamente se crea un archivo .class

Page 2: Compilación con DOS

3. Aquí tenemos la pantalla del programa ejecutándose correctamente

Código del programa:

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package arreglos2;

import java.io.BufferedReader;

import java.io.InputStreamReader;

/**

*

* @author GRACE

*/

public class Arreglos2 {

/**

* @param args the command line arguments

Page 3: Compilación con DOS

*/

public static void main(String[] args) throws Exception{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.print("Ingrese n: ");

int n = Integer.parseInt(br.readLine());

int vector[] = new int[n];

for (int i = 0; i < n; i++)

{

System.out.print("Ingrese el valor en la posicion "+i+": ");

vector[i] = Integer.parseInt(br.readLine());

}

int aux;

if(n%2==0)

{

for (int i = 0; i < (n/2); i++)

{

for (int j = i; j < (n/2); j++)

{

if(vector[i]>vector[j]){

aux = vector[i];

vector[i]=vector[j];

vector[j]=aux;

}

}

}

for (int i = (n/2); i < n; i++)

{

for (int j = i; j < n; j++)

{

if(vector[i]<vector[j])

{

aux = vector[i];

vector[i]=vector[j];

vector[j]=aux;

}

}

}

}

else

{

Page 4: Compilación con DOS

for (int i = 0; i < n; i++)

{

for (int j = i; j < n; j++)

{

if(vector[i]>vector[j])

{

aux = vector[i];

vector[i]=vector[j];

vector[j]=aux;

}

}

}

}

for (int i = 0; i < n; i++)

{

System.out.print(vector[i]+",");

}

}

}