TOPIC
PROBLEM 1467 - URI Fórum 1.0
This topic was solved and cannot recieve new replies.
-
ggroth replied 9 years ago
Você pode fazer da seguinte forma:
while(scanf("%d %d %d",&A,&B,&C) != EOF){ ... }
-
lfcduarte replied 9 years ago
como uso o EOF para fazer o laço do programa parar?
#include<stdio.h> int main(){ int A; int B; int C; char vencedor; scanf("%d %d %d",&A,&B,&C); if(A!=B && A!=C){ vencedor='A'; } else{ if(B!=A && B!=C){ vencedor='B'; } else{ if(C!=A && C!=B){ vencedor='C'; } else{ vencedor='*'; } } } printf("%c",vencedor); return(0); }
-
joyce3 replied 7 years ago
while True: l = input().split() a = int(l[0]) b = int(l[1]) c = int(l[2]) if a==0 and b==0 and c==0: print("*") a = b = c = 0 elif a==1 and b==1 and c==0: print("C") a = b = c = 0 elif a==1 and b==0 and c==0: print("A") a = b = c = 0 elif a==1 and b==0 and c==1: print("B") a = b = c = 0 elif a==1 and b==1 and c==1: print("*") a = b = c = 0 elif a==0 and b==0 and c==1: print("C") a = b = c = 0 elif a==0 and b==1 and c==0: print("B") a = b = c = 0 elif a==0 and b==1 and c==1: print("A") a = b = c = 0 elif a==1 and b==0 and c==1: print("B") a = b = c = 0
Gostaria de saber como fazer o final da entrada com o EOF dessa questão, lembrando que ela está em Python 3. Alguém pode me ajudar? por favor, agradeço desde já!
-
boliveira13 replied 8 years ago
Estou tendo o erro de 'Wrong answer' no meu código. O que seria o EOF que o enunciado pede? Seria a falta disso que estaria causando o erro?
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner t = new Scanner (System.in); int a; int b; int c; // condição para A ser 0 ou 1 do { a = t.nextInt(); } while (a != 0 && a != 1); // condição para B ser 0 ou 1 do { b = t.nextInt(); } while (b != 0 && b != 1); // condição para C ser 0 ou 1 do { c = t.nextInt(); } while (c != 0 && c != 1); // impressão if ( a==b && a != c ) { System.out.println("C"); } if ( a == c && a != b ) { System.out.println("B"); } if (b == c && b != a) { System.out.println("A"); } if (a == b && a == c) { System.out.println("*"); } } }
-
scrusher replied 9 years ago
Por que Runtime Error?
resp = [] while True: linha = raw_input() if not linha: break if linha == "0 0 0" or linha == "1 1 1": resp.append("*") else: if linha[0] == linha[2]: resp.append("C") elif linha[0] == linha[4]: resp.append("B") else: resp.append("A") for r in resp: print r
-
Heringer replied 9 years ago
Alguém pode me explicar o que é o:
Possible runtime error.
E por que da isto no meu código.
import java.util.Scanner; public class Main { public static void main (String [] args){ Scanner input = new Scanner(System.in); int a, b, c; while(input.hasNextLine()){ a = input.nextInt(); b = input.nextInt(); c = input.nextInt(); if (a == b && b == c){ System.out.println("*"); } if (a == b && b != c){ System.out.println("C"); } if (a == c && b != c){ System.out.println("B"); } if (c == b && a != c){ System.out.println("A"); } } } }
-
gmbarbosa replied 9 years ago
Deu "Presentation error" alguém sabe me dizer porque?
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner tec = new Scanner(System.in); int A,B,C; while(tec.hasNextInt()){ A = tec.nextInt(); B = tec.nextInt(); C = tec.nextInt(); if(A == 0 || A == 1 && B == 0 || B == 1 && C == 0 || C == 1){ if(A != B && A != C && B == C){ System.out.println("A\n"); }else if(B != A && B != C && A == C){ System.out.println("B\n"); }else if(C != A && C != B && A == B){ System.out.println("C\n"); }else if(A == B && A == C){ System.out.println("*\n"); } } } } }
-
fgoulart replied 9 years ago
-
dyeimys replied 9 years ago
[Como tratar EOF em Java] Boa Tarde pessoal, Estou resolvendo este problema emJavamas nunca dei conta de resolver um onde a parada é solicitada com EOF. Esta me retornando Possible runtime error, segue meu código:
//IMPORTS public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); String t = in.readLine(); int A, B, C; while (!(t.equals(""))) { A = Integer.parseInt(t.split(" ")[0]); B = Integer.parseInt(t.split(" ")[1]); C = Integer.parseInt(t.split(" ")[2]); //COMPARAÇOES t = in.readLine(); } out.flush(); } }
O meu EOF trato assim: **
while (!(t.equals("")))
**
-
AEUEUAUEAHUEAUEUA replied 9 years ago
Por que o código está dando Wrong Answer ?
i
import java.util.Scanner; import java.util.Locale; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); Locale.setDefault(Locale.US); int A , B , C; do { A = input.nextInt(); }while((!(A == 0) && !(A == 1)) ); do { B = input.nextInt(); }while( !(B == 0) && !(B == 1) ); do { C = input.nextInt(); }while(!(C == 0) && !(C == 1)); if(A == 0 && B == 1 && C == 1){ System.out.println("A"); } if(A == 1 && B == 0 && C == 1){ System.out.println("B"); } if(A == 1 && B == 1 && C == 0){ System.out.println("C"); } if(A == 1 && B == 0 && C == 0){ System.out.println("A"); } if(A == 0 && B == 1 && C == 0){ System.out.println("B"); } if(A == 0 && B == 0 && C == 1){ System.out.println("C"); } if(A == 0 && B == 0 && C == 0){ System.out.println("*"); } if(A == 1 && B == 1 && C == 1){ System.out.println("*"); } } }
-
lortiz replied 9 years ago
Não entendi o EOF nesse caso..
Segue meu código abaixo, dando Time limit exceeded
Código resolvido.
-
ggroth replied on Mar 1 2014
Inicialmente, vc postou tua dúvida no lugar errado. Os posts aqui são para o problema 1467. Favor tomar cuidado da próxima vez.
Remova os "\b" do teu printf, e imprima uma quebra de linha no final, e vc receberá AC.
Obs: Poste teu código entre as tags code, para que o fórum fique organizado.
-
erjunior0 replied on Mar 1 2014
Fiz exatamente o que foi pedido no enunciado do problema 1001. E sempre ganho Wrong answer! Ajudem por favor.
#include<stdio.h> int main(){ int A, B; scanf("%d", &A); scanf("%d", &B); printf("X \b=\b %d", A+B); return 0; }
-
crbonilha replied on Dec 6 2013
Ah sim. O enunciado do problema especifica:
Ou seja, seu programa deve ser capaz de repetir diversas vezes, e não apenas uma vez.
Esperimente fazer isso:
while(cin >> A >> B >> C) {
-
ltpadilha0 replied on Dec 5 2013
Código retirado. Duvida esclarecida.
Alguém pode me ajudar? O que tem de errado ?