Roy and Profile Picture

Roy wants to change his profile picture on Facebook. Now Facebook has some restrictions over the dimension of the picture that we can upload.

The minimum dimension of the picture can be L x L, where L is the length of the side of the square.

Now Roy has N photos of various dimensions.
Dimension of a photo is denoted as W x H
where W - width of the photo and H - Height of the photo

When any photo is uploaded following events may occur:

[1] If any of the width or height is less than L, the user is prompted to upload another one. Print "UPLOAD ANOTHER" in this case.
[2] If width and height, are large enough and
(a) if the photo is already square then it is accepted. Print "ACCEPTED" in this case.
(b) else user is prompted to crop it. Print "CROP IT" in this case.

(quotes are only for clarification)

Given L, N, W, and H as input, print appropriate text as output.

Example:

Input:  l = 180, w = 640, h = 480
Output: CROP IT

Approach

C++

#include <bits/stdc++.h>
using namespace std;

void profilePicture(int lint wint h)
{
    if (w < l || h < l)
        cout << "UPLOAD ANOTHER\n";
    else if (w == h && w >= l && h >= l)
        cout << "ACCEPTED\n";
    else
        cout << "CROP IT\n";
}

int main()
{
    int l = 180;

    int w = 640h = 480;

    profilePicture(lwh);

    return 0;
}


No comments:

Post a Comment