(URI) Identificando o Chá - Solução
import java.io.*;
class Main {
public static int leitor(BufferedReader br) throws NumberFormatException, IOException {
int n;
int resp = 0;
while (true) {
n = br.read();
if (n >= '0' && n <= '9') {
break;
}
}
while (true) {
resp = resp*10 + n-'0';
n = br.read();
if (n < '0' || n > '9') {
break;
}
}
return resp;
}
public static int verify(int tea, BufferedReader br) throws NumberFormatException, IOException {
int count = 0;
for (int i = 0; i < 5; i++) {
int answer = leitor(br);
if (answer == tea) {
count++;
}
}
return count;
}
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int tea = leitor(br);
System.out.println(verify(tea, br));
}
}
class Main {
public static int leitor(BufferedReader br) throws NumberFormatException, IOException {
int n;
int resp = 0;
while (true) {
n = br.read();
if (n >= '0' && n <= '9') {
break;
}
}
while (true) {
resp = resp*10 + n-'0';
n = br.read();
if (n < '0' || n > '9') {
break;
}
}
return resp;
}
public static int verify(int tea, BufferedReader br) throws NumberFormatException, IOException {
int count = 0;
for (int i = 0; i < 5; i++) {
int answer = leitor(br);
if (answer == tea) {
count++;
}
}
return count;
}
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int tea = leitor(br);
System.out.println(verify(tea, br));
}
}
Comments
Post a Comment