UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 22 de abril de 2015

Problema Resuelto 06



06.- INVERTIR UN NUMERO DE 5 DIGITOS

Resultado de imagen para inverso

* To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema06;
import java.io.*;
/**
 *
 * @author abel montalvan
 */
public class PROBLEMA06 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)  throws IOException {
        // TODO code application logic here
    
    int  n, ni, r;
     BufferedReader in =new BufferedReader(new  InputStreamReader(System.in));
 System.out.println("Número: ");
        n=Integer.parseInt(in.readLine());
    
        r=n%10;
        n=n/10;
        ni=r*10;
        
        r=n%10;
        n=n/10;
        ni=(ni+r)*10;
        
        r=n%10;
        n=n/10;
        ni=(ni+r)*10;
        
        r=n%10;
        n=n/10;
        ni=(ni+r)*10;
        
        ni=ni+n;
        
        System.out.println("");
      System.out.println("Inverso: " + ni);
        
    }
}

No hay comentarios:

Publicar un comentario