왜 wrong answer일까요..? 출력은 아무이상없는데 ㅠㅠ

kassuass Reply 9 years 9 weeks ago
import java.util.Scanner; import java.lang.Math; public class Main2{ public static void main(String[] args) { Scanner First = new Scanner(System.in); double form = First.nextDouble(); double a = (int)(form/1000000000); double b = (int)((form/10000000*10)*0.1); double c = (int)((form/1000000*10)*0.1) - b*10; double d = (int)((form/100000*10)*0.1) - b*100 - c*10; double e = (int)((form/10000*10)*0.1) - b*1000 - c*100 - d*10; double f = (int)((form/1000*10)*0.1) - b*10000 - c*1000 - d*100 - e*10; double g = (int)((form/100*10)*0.1) - b*100000 - c*10000 - d*1000 - e*100 - f*10; double h = (int)((form/10*10)*0.1) - b*1000000 - c*100000 - d*10000 - e*1000 - f*100 - g*10; double i = (int)((form/1*10)*0.1) - b*10000000 - c*1000000 - d*100000 - e*10000 - f*1000 - g*100 - h*10; double x = (a*1 + b*2 + c*3 + d*4 + e*5 + f*6 + g*7 + h*8 + i*9)%11; double equation = (a*1000000000 + b*100000000 + c*10000000 + d*1000000 + e*100000 + f*10000 + g*1000 + h*100 + i*10 + x); System.out.printf("%d", (int)(a)); System.out.printf("%d", (int)(b)); System.out.printf("%d", (int)(c)); System.out.printf("%d", (int)(d)); System.out.printf("%d", (int)(e)); System.out.printf("%d", (int)(f)); System.out.printf("%d", (int)(g)); System.out.printf("%d", (int)(h)); System.out.printf("%d", (int)(i)); if(x==10){ System.out.printf("X"); } else{ System.out.printf("%d", (int)(x)); } } }
pichulia Reply 9 years 9 weeks ago
뭔가 a를 빼먹었다는 느낌이 들지 않습니까? 맨 처음 숫자가 0이 아닌 다른숫자로 시작하면 결과값이 이상하게 나올겁니다..ㅠㅠ
kassuass Reply 9 years 9 weeks ago
아... 감사합니다!! 다음에는 좀 더 꼼꼼하게 체크하고 discuss에 올리겠습니다 ㅠㅠ