0
Hay forma de hacer esto? Debo hacerlo para la universidad, ayuda por favor :(
4 odpowiedzi
0
Debe probar y publicar su prueba. Puede utilizar el método de subcadena s.substring (i, i + 2); para extraer 2 caracteres y comparar.
Puede usar un bucle y hacer como string.charAt (i) == string.charAt (i + 1) && (string.charAt (i)! = 'R' || string.charAt (i)! = 'L' ))
en bucle .. Espero que ayude ..
(translated this)
You need to try and please post your try.. You can use substring method s.substring(i,i+2); to extract 2 charecters and compare.
You can use a loop and do like string.charAt(i) == string.charAt(i+1) && (string.charAt(i)! ='R' || string.charAt(i)!='L'))
in loop.. Hope it helps..
0
Jayakrishna🇮🇳 Could you make the code for me please? 🙏 is for tomorrow😞
0
You are saying to me to make a crime almost..
You should atleast give a try.. I almost given main condition for your problem.. You just need to take input and add a loop..
0
Miguel Ángel Puerta Reyes
Only this time, please never ask only code to any one , pls try yourself first..
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str=in.next();
boolean s=false;
for(int i =0; i<str.length()-1;i++){
if(str.charAt(i) == str.charAt(i+1))
if(str.charAt(i)!='R' && str.charAt(i)!='L'))
{
s = true;
break;
}
}
System.out.println(s);
// by using substring method
/*
if(str.contains("RR") || str.contains("LL"))
System.out.println(false);
else
for(int i =0; i<str.length()-1;i++){
if(str.charAt(i) == str.charAt(i+1))
{
s = true;
break;
}
}
System.out.print(s);
*/
}
}