Monday, July 04, 2016

URI Online Judge Solution : 1013 The Greatest (Beginner Problem)

Posted by LIfe2Coding on Monday, July 04, 2016 in | No comments

URI Online Judge | 1013

The Greatest

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Make a program that reads 3 integer values and present the greatest one followed by the message "eh o maior". Use the following formula:

Input

The input file contains 3 integer values.

Output

Print the greatest of these three values followed by a space and the message “eh o maior”.
Input SamplesOutput Samples
7 14 106106 eh o maior
217 14 6217 eh o maior

Solution


#include<stdio.h>
#include <math.h>

int main()
{
	int A, B, C;
	int maiorAB,maiorAC,maiorBC;
	
	scanf("%d %d %d", &A, &B, &C);
	maiorAB = (A + B + abs(A - B)) / 2;
	maiorAC = (maiorAB + C + abs(maiorAB - C)) / 2;


	printf("%d eh o maior\n", maiorAC);
	return 0;
}

0 comments:

Post a Comment