View Code of Problem 3697

#include<iostream>
using namespace std;
int main()
{
	int t;
	scanf("%d",&t);
	while(t --)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		if(a < b)
		{
			for(int i = a;i <= b;i ++)
			{
				printf("%d frogs have %d mouths, %d eyes and %d legs, jump into the water with ",i,i,2*i,4*i);
				int k = i;
				while(k --)
				{
					if(k != 0) cout << "splash ";
					else cout << "splash.";
				}
				cout << endl;
			}
		}
		else
		{
			for(int i = b;i >= a;i --)
			{
				printf("%d frogs have %d mouths, %d eyes and %d legs, jump into the water with ",i,i,2*i,4*i);
				int k = i;
				while(k --)
				{
					if(k != 0) cout << "splash ";
					else cout << "splash.";
				}
				cout << endl;
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3697