“Sometimes it is the people no one can imagine anything of who do the things no one can imagine.” ― Sir Alan Turing


ADS

ADS

Monday, November 7, 2016

URI 1013 - The Greatest || Solution in C / C++



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

SOURCE CODE

#include<iostream>

#include<cstdio>

#include<cstdlib>

int main() {
  int a, b, c, MaiorAB, maior;
  scanf("%d %d %d", & a, & b, & c);
  MaiorAB = (a + b + abs(a - b)) / 2;
  maior = (MaiorAB + c + abs(MaiorAB - c)) / 2;
  printf("%d eh o maior\n", maior);
  return 0;
}

No comments:

Post a Comment