View Code of Problem 3697

#include<iostream>
using namespace std;
int main()
{
	int n,a,b,temp;
	cin>>n;
	while(n--)
	{ 
	   cin>>a>>b;
	  if(a<b)
	   {
	     for(int i=a;i<=b;i++)
	     {
	   	   if(i==1){
	   	   	cout<<"1 frog has 1 mouth, 2 eyes and 4 legs, jumps into the water with a splash."<<endl;
			  }
	   	 else{
			  
	   	 cout<<i<<" frogs have "<<i<<" mouths, "<<i*2<<" eyes and "
	   	   <<i*4<<" legs, jump into the water with";
	   	
	   	 for(int j=0;j<i;j++)
	   	  cout<<" splash";
	   	 
	   	 cout<<"."<<endl;
	        }		 
	     }
       }	 
	 else {
	 	
	 	for(int i=a;i>=b;i--)
	 	{
	 		if(i==1){
	 			cout<<"1 frog has 1 mouth, 2 eyes and 4 legs, jumps into the water with a splash."<<endl;
			 }
	 		
	 	else {
		 	
		 cout<<i<<" frogs have "<<i<<" mouths, "<<i*2<<" eyes and "
	   	   <<i*4<<" legs, jump into the water with";
	 			
	 	for(int j=0;j<i;j++)
	   	  cout<<" splash";
	   	
		   cout<<"."<<endl; 
	   	
		 }
	 }
     }
	 
  } 
}

Double click to view unformatted code.


Back to problem 3697