import java.util.*;
public class Main {
static long factos[]=new long[25];
static long factorial(int z)
{
long fac=1;
for(int i=1;i<=z;i++)
fac=fac*i;
return fac;
}
static int MAX=100;
static int a1[]=new int[MAX];
static void rellenaraleatorios(int x[])
{
for(int i=0;i<x.length;i++)
{
x[i]=(int)(Math.random()*100+1);
}
}
static void imprimir(int x[])
{
for(int i=0;i<x.length;i++)
{
if(i%10==0)
System.out.print(" \n ");
System.out.print(" "+(i+1));
}
}
static void imprimir(long x[],String nombre)
{
for(int i=0; i<x.length;i++)
{
System.out.println(nombre+"\t["+(+i+1)+"]="+x[i]+"\t");
//if(i%5==0)System.out.println("\t");
System.out.println("");
}
}
static long [] rellenarfactorial(long x[])
{
for(int i=1;i<x.length+1;i++)
x[i-1]=factorial(i);
return x;
}
public static void main(String[] args) {
// Your code here!
String strNumero1;
String strNumero2;
int intNumero1;
int intNumero2;
int total;
rellenaraleatorios(a1);
imprimir(a1);
System.out.print(" \n ");
rellenarfactorial(factos);
imprimir(factos,"factos");
intNumero1 = 5;
intNumero2 = 8;
total = intNumero1 + intNumero2;
System.out.print(" \n ");
System.out.println("Suma="+total);
System.out.println("MATRIZ ALEATORIA");
int s;
s=0;
int n;
n=5;
int matriz[][] = new int[5][5];
for (int x=0; x < n; x++)
{
for (int y=0; y < n; y++)
{
s=s+1;
matriz[x][y] = s;
//matriz[x][y] = (int) (Math.random()*9+1);
}
}
n=5;
n=matriz.length;
for (int x=0; x <n ; x++)
{
for (int y=0; y < n; y++) {
System.out.print(matriz[x][y] + " ");
}
System.out.println(" ");
}
System.out.println("Entrada 45 ");
for (int y=0; y <n ; y++)
{
for (int x=0; x < n; x++) {
System.out.print(matriz[x][y] + " ");
}
System.out.println(" ");
}
System.out.println("Entrada 56 ");
}
}
No hay comentarios:
Publicar un comentario