import java.util.Scanner;
public class work
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner (System.in);
System.out.println("輸入一個數字");
int a = keyboard.nextInt();
double i = 1,j = 0,k = 0,z;
for(z=0; z<=a; z++)
{
k = i+j;
if(z!= 100)
System.out.printf("%5.0e + %5.0e\t" ,j,i);
else
System.out.printf("%5.0f + %5.0f\t" ,j,i);
j = i;
i = k;
if (z!= 100)
System.out.printf("=\t%.0e\n" ,i);
else
System.out.printf("=\t%.0f\n", i);
double o=k, p=j, m=o/p;
System.out.printf("the ratio %5f\n", m);
}
}
}
public class work
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner (System.in);
System.out.println("輸入一個數字");
int a = keyboard.nextInt();
double i = 1,j = 0,k = 0,z;
for(z=0; z<=a; z++)
{
k = i+j;
if(z!= 100)
System.out.printf("%5.0e + %5.0e\t" ,j,i);
else
System.out.printf("%5.0f + %5.0f\t" ,j,i);
j = i;
i = k;
if (z!= 100)
System.out.printf("=\t%.0e\n" ,i);
else
System.out.printf("=\t%.0f\n", i);
double o=k, p=j, m=o/p;
System.out.printf("the ratio %5f\n", m);
}
}
}
沒有留言:
張貼留言