import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class test {
public static void main(String[] args) throws IOException {
BufferedReader ip = new BufferedReader(new InputStreamReader(System.in));
long a=0, b=1, c;
int n;
System.out.print("몇 번째 항까지 출력합니까? ");
n = Integer.parseInt(ip.readLine());
for(int i=1; i<=n; i++) {
c = a + b;
a = b;
b = c;
System.out.printf("%ld ",c); <-------------------------- 이부분
-----------------------------------------------------------------
피보나치 연습문제 풀었는데 long형이라 %ld로 했거든 근데 에러나더라구
Exception in thread "main" java.util.UnknownFormatConversionException: C
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.<init>(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.io.PrintStream.format(Unknown Source)
at java.io.PrintStream.printf(Unknown Source)
at 1test.main(test.java:194)
이거 %d로 하면 잘 출력되는데 왜 long형에 맞게 %ld로 쓰면 에러나는거임?
lf 아님?
혹시 몰라서 lf 해봤는데 에러나
아 미안 .. double 생각했다
늬구내의믈잇부믜라거헤소오려라븨용싀세긔야이럴대소모그라고인는븨해온글슈긔당:p
ㅇㅋ
보니까 그냥 d로 출력해도 잘나오네... l이나 L안먹히는거 보니까 따로 출력하는건 없는듯
또 d로 출력한다고 짤리거나 하는거 없는거보니까 문제도 없는것같고
그런가.. 그럼 그냥 d로 알고있어야겠네