코드가 잘 동작하는 것 같은데... 막상 제출을 하면 오답이 뜨네요... 혹시 어느 부분이 잘못된건지 여쭤봐도 될까요!?
importjava.util.Arrays;importjava.util.Scanner;publicclassMain{// 필요한 배열staticint[]number=newint[]{0,1,2,3,4,5,6,7,8,9,10};staticString[]charNumber=newString[]{"zero","one","two","three","four","five","six","seven","eight","nine","ten"};staticbooleancheck(intanum,Stringb){Stringa=charNumber[anum];if(a.length()!=b.length())returnfalse;String[]aArray=a.split("");String[]bArray=b.split("");Arrays.sort(aArray);Arrays.sort(bArray);intcount=0;for(inti=0;i<aArray.length;i++){if(aArray[i].equals(bArray[i]))count++;}if(count==aArray.length)returntrue;elsereturnfalse;}publicstaticvoidmain(String[]args){Scannerscan=newScanner(System.in);inttimes=scan.nextInt();scan.nextLine();for(intt=0;t<times;t++){Stringfirst=scan.next();Stringop=scan.next();Stringsecond=scan.next();scan.next();// = 을 제거해 주기 위해서!Stringresult=scan.next();scan.nextLine();intcount=0;for(inti=0;i<11;i++){if(first.equals(charNumber[i]))count=i;}intfirstnum=number[count];for(inti=0;i<11;i++){if(second.equals(charNumber[i]))count=i;}intsecondnum=number[count];for(inti=0;i<11;i++){if(result.equals(charNumber[i]))count=i;}intresultnum=number[count];intcal=0;switch(op){case"+":cal=firstnum+secondnum;break;case"-":cal=firstnum-secondnum;break;case"*":cal=firstnum*secondnum;break;default:System.out.println("Fucking Error");break;}if(cal<0||cal>10)System.out.println("No");else{if(cal==resultnum)System.out.println("Yes");else{if(check(cal,result))System.out.println("Yes");elseSystem.out.println("No");}}}}}
tjtjdgur34
코드가 잘 동작하는 것 같은데... 막상 제출을 하면 오답이 뜨네요... 혹시 어느 부분이 잘못된건지 여쭤봐도 될까요!?
7년 전