View Code of Problem 3697

#include<stdio.h>
int main(){
	int n,i,j;
	scanf("%d",&n);
	while(n--){
		scanf("%d %d",&i,&j);
		if(i<j){
		for(int a=i;a<=j;a++){
			if(a>1){
		printf("%d frogs have %d mouths, %d eyes and %d legs, jump into the water with ",a,a,2*a,4*a);
		for(int b=0;b<a-1;b++)
		printf("splash ");
		printf("splash.\n");
		}
		else
		printf("1 frog has 1 mouth, 2 eyes and 4 legs, jumps into the water with a splash.\n");
		}
	}
	else{
	   for(int a=i;a>=j;a--){
			if(a>1){
		printf("%d frogs have %d mouths, %d eyes and %d legs, jump into the water with ",a,a,2*a,4*a);
		for(int b=0;b<a-1;b++)
		printf("splash ");
		printf("splash.\n");
		}
		else
		printf("1 frog has 1 mouth, 2 eyes and 4 legs, jumps into the water with a splash.\n");
		}	
	}
}
} 

Double click to view unformatted code.


Back to problem 3697