I2ichard's profilel2ICHARD PhotosBlogListsMore ![]() | Help |
|
|
6/5/2008 PRACTICA 1103 EJERCICIOS RESUELTOS EN JAVA
Contar los digitos
import java.io.*; public class preg2{ public static void main(String args[]) throws NumberFormatException, IOException{ int número=0, n=0,dígitos = 0; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Ingrese numero : "); número = Integer.parseInt(in.readLine( ));
while ( número > 0 ) { número /=10; dígitos++; if (dígitos ==n) break; } // if (dígitos ==n) System.out.println("los digitos del numero son: " +dígitos); }
|
|
|