Arreglos

Páginas: 2 (260 palabras) Publicado: 25 de enero de 2012
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

import java.util.Random;
import javax.swing.JOptionPane;
/**
*
* @author Fam.Garcia*/
public class TareaLuis {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

String aux;
String aux1="";String aux2="";
String aux3="";

int n;
int num;
int in=0;
int posicion;
int nuevonumero;aux=JOptionPane.showInputDialog("De que magnitud quieres el arreglo");
n=Integer.parseInt(aux);
posicion=n-1;

int arreglos[]=new int[n];

for(inti=0;i<arreglos.length;i++){
Random rnd = new Random();
arreglos[i]=(int)(rnd.nextDouble()*n);
if(i<(n-1))aux1+=arreglos[i]+", ";
elseaux1+=arreglos[i];
}
JOptionPane.showMessageDialog(null, "Los numeros del arreglo son "+"proximo\n"+aux1);
aux=JOptionPane.showInputDialog("Introduce el numero que "+"buscas");num=Integer.parseInt(aux);
for(int i=0;i<arreglos.length;i++){

if(arreglos[i]==num){
if(i<posicion) aux2+=(i+1)+", ";else aux2+=(i+1);
in++;
int arreglo2 [] = new int [in];
for(int r=0;r<arreglo2.length;r++){
arreglo2[r]=num;
}}
}
if(in>0){
JOptionPane.showMessageDialog(null, "El numero que solisitaste si existe" + "se encuentra\n en la posicion: "+aux2);
for(intt=0;t<arreglos.length;t++){
if (arreglos[t]==num){
aux=JOptionPane.showInputDialog("introduse el nuevo "+ "numero");
nuevonumero=Integer.parseInt(aux);...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Arreglos
  • Arreglos
  • Arreglos
  • Arreglos
  • Arreglos
  • Arreglos
  • Arreglos
  • ARREGLOS

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS