
25/08/2010, 20:34
|
| | Fecha de Ingreso: agosto-2010
Mensajes: 126
Antigüedad: 14 años, 6 meses Puntos: 9 | |
Respuesta: piramide numerica te voy a dar una idea como tenes que hacerlo...
public static void main(String[] args) throws IOException {
// TODO code application logic here
int cant = 4;
for(int i=0; i< cant; i++){
if(i==0){
System.out.println(" "+(i+1));
i++;
}
int k = ((i*2)+(i+1));
int p=1;
int s = 2;
for(int j=i+1; j<=k; j++){
if(p<=k/2){
System.out.print(" "+ j +" ");
p++;
}
else{
System.out.print(" "+(j-s)+ " ");
s +=2;
}
}
System.out.println("");
}
}
revisalo bien y modificalo, para que este completo tal como queres que te muestre el resultado... |