View Code of Problem 3697

#include <iostream>
#include<stdio.h>
#include <string.h>
#include<cstring>
#include <math.h>
#include<algorithm>
#include <stack>
using namespace std;


int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int x, y;
		cin >> x >> y;
		if (x <= y) {
			for (int i = x; i <= y; i++) {
				int mouths = i;
				int eyes = 2 * i;
				int legs = 4 * i;
				cout << i << " frogs have " << mouths << " mouths, " << eyes << " eyes and " << legs << " legs, jump into the water with";
				for (int k = 0; k < i; k++) {
					cout << " splash";
				}
				cout << "." << endl;
			}
		}
		else {
			for (int i = x; i >= y; i--) {
				int mouths = i;
				int eyes = 2 * i;
				int legs = 4 * i;
				cout << i << " frogs have " << mouths << " mouths, " << eyes << " eyes and " << legs << " legs, jump into the water with";
				for (int k = 0; k < i; k++) {
					cout << " splash";
				}
				cout << "." << endl;
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3697