#19525: 請教各位大佬,為什麼他一直給我WA(共輸出0行)QAQ


uhjio1233@gmail.com (王日熙)

學校 : 不指定學校
編號 : 99801
來源 : [101.137.64.46]
最後登入時間 :
2020-05-20 09:56:38
e283. APCS 類似題 - 小崴的特殊編碼 -- 小崴系列APCS | From: [101.137.224.163] | 發表日期 : 2019-10-07 20:53

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
class APCS1{
public static void main(String arg[]) throws Exception {
try {
Scanner cin=new Scanner(System.in);
int comin;
while(cin.hasNext()) {
int cir=0;int i=0;
cir=cin.nextInt();
String output="";
while(cir>0) {
BufferedReader Bcin=new BufferedReader(new InputStreamReader(System.in));
String input=Bcin.readLine();
String[] arr= {"A","B","C","D","E","F"};
String arrcod[]= {"0 1 0 1","0 1 1 1","0 0 1 0","1 1 0 1","1 0 0 0","1 1 0 0"};
for(i=0;i<=5;i++) {
comin=input.compareTo(arrcod[i]);
if(comin==0) {
output+=arr[i];
}
}
cir--;
}
System.out.println(output);
}
}
catch(Exception e) {
e.printStackTrace();
}
}
}

 
#37890: Re: 請教各位大佬,為什麼他一直給我WA(共輸出0行)QAQ


zhoudaniel02@gmail.com (周孝倫)

學校 : 銘傳大學
編號 : 235507
來源 : [120.125.89.13]
最後登入時間 :
2024-10-04 15:44:35
e283. APCS 類似題 - 小崴的特殊編碼 -- 小崴系列APCS | From: [223.137.183.81] | 發表日期 : 2023-10-16 17:18

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
class APCS1{
public static void main(String arg[]) throws Exception {
try {
Scanner cin=new Scanner(System.in);
int comin;
while(cin.hasNext()) {
int cir=0;int i=0;
cir=cin.nextInt();
String output="";
while(cir>0) {
BufferedReader Bcin=new BufferedReader(new InputStreamReader(System.in));
String input=Bcin.readLine();
String[] arr= {"A","B","C","D","E","F"};
String arrcod[]= {"0 1 0 1","0 1 1 1","0 0 1 0","1 1 0 1","1 0 0 0","1 1 0 0"};
for(i=0;i<=5;i++) {
comin=input.compareTo(arrcod[i]);
if(comin==0) {
output+=arr[i];
}
}
cir--;
}
System.out.println(output);
}
}
catch(Exception e) {
e.printStackTrace();
}
}
}

為啥要宣告兩個BufferedReader

 
ZeroJudge Forum