TÓPICO
WA 100% Help please
tmaharani perguntou 4 years ago
So, im trying this for so long, and with a lot of diferents codes, can someone help me? why this has WA?
public class Main {
static InputStreamReader ir = new InputStreamReader(System.in);
static BufferedReader in = new BufferedReader(ir);
public static int buildObjetos(LinkedList<Integer> objetos, int n) throws IOException {
while (n != 0) {
n--;
int inicio = 0, fim = 0;
inicio = in.read();
fim = in.read();
if(inicio > fim || inicio > 100 || fim > 100 || inicio < 1 || fim < 1) {
return -1;
}
while (inicio <= fim) {
objetos.add(inicio);
inicio++;
}
}
return 0;
}
public static void main (String[] args) throws IOException {
while (in.ready()) {
int n = in.read();
if(n > 100 || n < 1) {
break;
}
LinkedList<Integer> objetos = new LinkedList<>();
int exit = buildObjetos(objetos, n);
if(exit == -1) {
break;
}
objetos.sort(null);
int s = in.read();
if(s > 100 || s < 1 || objetos.size() > 10000) {
break;
}
int ini = objetos.indexOf(s);
int fin = objetos.lastIndexOf(s);
if(ini == -1) {
System.out.println(s + " not found");
}else {
System.out.println(s + " found from " + ini + " to " + fin);
}
n = 0;
} } }
Este tópico ainda não foi respondido. Seja o primeiro!