[URI Online Judge] – 1013 – The greatest

Make a program that read 3 integer numbers and print the greatest one using the following formula:

Input

The input file contain 3 integer numbers.

Output

Print the greatest of these three values followed by a space and the message “eh o maior”.

Sample Inputs Sample Outputs
7 14 106 106 eh o maior
217 14 6 217 eh o maior

Solution:

#include <cstdio>
#include <cmath>

int main(){
int a, b, c, m;
scanf(“%d %d %d”, &a, &b, &c);
m = (a + b + std::abs(a – b)) / 2;
m = (m + c + std::abs(m – c)) / 2;
printf(“%d eh o maior\n”, m);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s