█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 4913

Problema 0x62 - Contar elementos mayores a X en un arreglo pequeño

  • Autor: diezgo1008
  • Fecha: 2021-09-15 01:53:41 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#2
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#3
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#4
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#5
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#6
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#7
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#8
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#9
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
#10
Error de compilación
                      Main.java:3: error: class, interface, or enum expected
public Main{
       ^
Main.java:5: error: class, interface, or enum expected
    public static void main(String[] args) {
                  ^
Main.java:7: error: class, interface, or enum expected
        int tamano = sc.nextInt();
        ^
Main.java:8: error: class, interface, or enum expected
        int cont1 = 0;
        ^
Main.java:9: error: class, interface, or enum expected
        int cont2 = 0;
        ^
Main.java:10: error: class, interface, or enum expected
        int cont3 = 0;
        ^
Main.java:12: error: class, interface, or enum expected
        int[] v = new int[tamano];
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:14: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:16: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                        ^
Main.java:17: error: class, interface, or enum expected
        for (int i = 0; i < v.length; i++) {
                                      ^
Main.java:21: error: class, interface, or enum expected
            }
            ^
Main.java:24: error: class, interface, or enum expected
            }
            ^
Main.java:27: error: class, interface, or enum expected
            }
            ^
Main.java:31: error: class, interface, or enum expected
        System.out.println(cont2);
        ^
Main.java:33: error: class, interface, or enum expected
        System.out.println(cont3);
        ^
Main.java:34: error: class, interface, or enum expected
    }
    ^
19 errors

                    
Puntos totales: 0 / 100

Código

import java.util.Scanner;

public Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int tamano = sc.nextInt();
        int cont1 = 0;
        int cont2 = 0;
        int cont3 = 0;

        int[] v = new int[tamano];

        for (int i = 0; i < v.length; i++) {
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < v.length; i++) {

            if (v[i] > 0) {
                cont1++;
            }
            if (v[i] > 1) {
                cont2++;
            }
            if (v[i] > 4) {
                cont3++;
            }
        }
        System.out.println(cont1);

        System.out.println(cont2);

        System.out.println(cont3);
    }
}