Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Ptov2 {
- public static void main(String[] args) {
- int n,i,j,cont1=0,cont2=0;
- double sum1=0,sum2=0;
- Scanner S=new Scanner(System.in);
- System.out.print("Cantidad de elementos a cargar: ");
- n=S.nextInt();
- int[]vec1 = new int[n];
- int[]vec2 = new int[n];
- for(i=0; i<n; i++) {
- System.out.print("Ingrese el elemento "+i+" del Vector 1: ");
- vec1[i]=S.nextInt();
- }
- System.out.println();
- for(i=0; i<n; i++) {
- System.out.print("Ingrese el elemento "+i+" del Vector 2: ");
- vec2[i]=S.nextInt();
- }
- System.out.println();
- //Suma(vec1,vec2,n);
- //ProductoEsc(vec1,vec2))1;
- for(j=0;j<vec1.length;j++) {
- sum1+=vec1[j];
- sum2+=vec2[j];
- }
- System.out.println("La media del vector 1 es: "+sum1/n);
- System.out.println("La media del vector 2 es: "+sum2/n);
- System.out.println();
- System.out.print("El/Los valor(es) del vector 1 que supera(n) su media son: ");
- for (j=0; j<vec1.length;j++) {
- if (vec1[j]>sum1/n) {
- System.out.print(vec1[j]+", ");
- cont1+=1;
- }
- }
- if(cont1==0) {
- System.out.println("***Ningun valor supera la media***");
- }
- System.out.println();
- System.out.print("El/Los valor(es) del vector 2 que supera(n) su media son: ");
- for (j=0; j<vec1.length;j++) {
- if (vec2[j]>sum2/n) {
- System.out.print(vec2[j]+", ");
- cont2+=1;
- }
- }
- if(cont2==0) {
- System.out.println("***Ningun valor supera la media***");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement