Txerrinko

Insercion

Mar 18th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. package Ejercicio9;
  2.  
  3. import java.io.IOException;
  4.  
  5. public class Insercion {
  6.  
  7.     /**
  8.      * @param args
  9.      * @throws IOException
  10.      */
  11.     public static void main(String[] args) throws IOException {
  12.         // TODO Auto-generated method stub
  13.         int i=0;
  14.         char [] caracteres=new char [20];
  15.         char num;
  16.         char resp=' ';
  17.         char carac,n;
  18.               do{
  19.                     System.out.println("Desea introducir otro caracter?");
  20.                     carac=Consola.leeChar();
  21.                 i++;  
  22.                
  23.                   System.out.print("Otro caracter");
  24.                   resp=Consola.leeChar();
  25.               }
  26.             while(i <100   && resp=='S');
  27.             //caracteres[i]=caracteres[i+1];
  28.        
  29.            
  30.        
  31.        
  32.         System.out.println("Introduzca numero");
  33.         num=Consola.leeChar();
  34.        
  35.         System.out.println("Introduzca posicion");
  36.         n=Consola.leeChar();
  37.        
  38.         char g=(char) caracteres.length;
  39.  
  40.         for ( i=(g-1);i>=(n-1);i--){
  41.            
  42.             caracteres[i+1]=caracteres[i];
  43.            
  44.             caracteres[n-1]=num;
  45.            
  46.             g++;
  47.            
  48.            
  49.         }
  50.        
  51.        
  52.        
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment