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

Envío 6974

Problema 0x5c - Decir si hay una letra repetida

  • Autor: andres
  • Fecha: 2023-04-18 03:40:00 UTC (Hace alrededor de 1 año)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.002 s 0 KBi
#2
Correcto
0.005 s 0 KBi
#3
Incorrecto
0.004 s 0 KBi
#4
Incorrecto
0.005 s 1 KBi
#5
Incorrecto
0.005 s 0 KBi
#6
Correcto
0.005 s 0 KBi
#7
Correcto
0.001 s 0 KBi
#8
Correcto
0.005 s 1 KBi
#9
Correcto
0.005 s 1 KBi
#10
Correcto
0.004 s 1 KBi
#11
Correcto
0.005 s 1 KBi
#12
Correcto
0.006 s 1 KBi
Puntos totales: 75 / 100

Código

#include <iostream>
#include <cassert>

using namespace std;

int main() {
    string text;
    int textLenght = 50;
    cin >> text;

    assert(text.length() <= textLenght);

    bool repeated = false;
    for (int i = 0; i <= text.length(); i++) {
        if (text[i] == text[i+1]) {
            repeated = true;
        }
    }
    
    if (repeated) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }

    return 0;
}