TOPIC
PROBLEM 2023 - URI Fórum 1.0
This topic was solved and cannot recieve new replies.
-
Murilo7 replied 7 years ago
Alguem pode me explicar pq Pedro vem depois de Salvador nesse problema ??
-
rnascimento11 replied 7 years ago
O que tem de errado com meu código? Todos os casos que tentei deram certo, mas recebo WA 100%.
l = [] while True: try: l.append(input()) if l[len(l) - 1] == '': l = sorted(l, key=str.lower) print(l[len(l) - 1]) quit() except: quit()
-
jgbneto replied 7 years ago
Gente, estou recebendo WA 50%, mas em todos os casos está funcionando! Alguém poderia ver o que estou fazendo de errado?
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner ler = new Scanner(System.in); int one=0, two,cont=0; String drink,nome = ""; String aux, aux2=""; while(ler.hasNextLine()){ String s = ler.nextLine(); aux = s.toLowerCase(); aux = aux.replace(" ", ""); if(cont==0){ nome = s.toLowerCase(); nome = nome.replace(" ", ""); aux2=s; }else{ for (int i = 0; i < Math.min(aux.length(),nome.length()); i++) { two=(int)aux.charAt(i); one=(int)nome.charAt(i); if(two<one){ break; }else if(two>one){ nome = aux; aux2=s; break; } } } cont+=1; } System.out.println(aux2); } }
-
tiwizard replied 7 years ago
stricmp é uma função exclusiva da microsoft (Acredito que só funcione em compiladores da microsoft). Uma alternativa é strcasecmp.
-
rsantana replied 7 years ago
Gente está dando Compilation error com as seguintes mensagens /tmp/cc7sW80V.o: In function
main': Main.c:(.text.startup+0x83): warning: the
gets' function is dangerous and should not be used. Main.c:(.text.startup+0xd0): undefined reference to `stricmp' collect2: error: ld returned 1 exit statusNessa parte que ele diz ser perigoso usar o gets se eu não usar o último exemplo não será validado como scanf.
A parte "undefined reference to stricmp" indica que o site não aceita usar a função?
#include <stdio.h> #include <string.h> int main () { char txt[81], maior[81]; fflush(stdin); gets (txt); strcpy(maior,txt); while ( strcmp(txt,"EOF")!=0) { if (stricmp(txt,maior)>0) strcpy(maior,txt); fflush(stdin); gets (txt); } printf ("%s\n", maior); return 0; }
-
lsdrocha replied 8 years ago
Você está ordenando o vetor várias vezes (o sort está dentro do while), isso deixa o código bem mais lento do que ordenar apenas uma vez depois que sair do while. Além disso, verifique sua função de comparação. Aqui no meu pc, o terceiro caso de teste de exemplo dá a resposta errada.