import java.lang.*;
import java.io.*;
public class Arreglos{
void llena_matriz(int []a)
{ int j;
for(j=0;j<20;j++)
{ a[j]=(int)(Math.random()*20);}
}
void imprime(int []c)
{ int i;
for(i=0;i<20;i++)
{ System.out.print(" "+c[i] ); }
System.out.println( );
}
int multi(int []x, int []y)
{ int total=0;
int s;
for(s=0;s<20;s++)
{ total= total + x[s]* y[s]; }
return total;
}
public static void main(String args[])
{ int tot;
int[] A= new int[20];
int[] B= new int[20];
Arreglos p=new Arreglos();
Arreglos o=new Arreglos();
System.out.println("***** Programa que suma 2 arreglos con Thread *****");
p.llena_matriz(A);
p.imprime(A);
o.llena_matriz(B);
o.imprime(B);
tot=o.multi(A,B);
System.out.println(tot);
}
}
|