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

Envío 5025

Problema 0x5c - Decir si hay una letra repetida

  • Autor: diezgo1008
  • Fecha: 2021-10-07 00:15:26 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#2
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#3
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#4
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#5
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#6
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#7
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#8
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#9
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#10
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#11
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
#12
Error de compilación
                      main.c:1:1: error: unknown type name 'public'
public class Main {
^
main.c:1:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
2 errors generated.

                    
Puntos totales: 0 / 100

Código

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String palabra = "";
		char[] letras;
		
		int repetir = 0;

		System.out.println("Escribe una frase: ");
		palabra = sc.nextLine();
		letras = palabra.toCharArray();

		for (int i = 0; i < letras.length; i++) {
			char letraActual = letras[i];
            int cont = 0;
			System.out.println(letraActual);
			for(int j = 0; j < letras.length; j++) {
				if(letras[j] == letraActual) 
					cont++;
				
				}
			if(repetir < cont) {
				repetir = cont;
			}
			 
		}
		if (repetir !=1) {
			System.out.println("yes");
		}else {
			System.out.println("no");
		}
		

	}
}