import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int N=scanner.nextInt(); for(int i=0;i<N;i++) { int K=scanner.nextInt(); int S=scanner.nextInt(); if (S>K) { for (int j = K; j <= S;j++) { if (j==1) { System.out.printf("%d frog has %d mouth, %d eyes and %d legs, jumps into the water with a splash.\n",j,j,j*2,j*4); }else { System.out.printf("%d frogs have %d mouths, %d eyes and %d legs, jump into the water with",j,j,j*2,j*4); } for (int j2 = 1; j2 < j; j2++) { System.out.print(" splash"); }if (j>1) { System.out.println(" splash."); } } }else { for (int j = K; j>=S ;j--) { if (j==1) { System.out.printf("%d frog has %d mouth, %d eyes and %d legs, jumps into the water with",j,j,j*2,j*4); }else { System.out.printf("%d frogs have %d mouths, %d eyes and %d legs, jump into the water with",j,j,j*2,j*4); } for (int j2 = 1; j2 < j; j2++) { System.out.print(" splash"); }if (j>1) { System.out.println("splash."); } } } } } } |
Double click to view unformatted code.