Wednesday, December 2, 2015

Uri problem 1013 solve

Problem :

The Greatest

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
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 InputsSample Outputs
7 14 106106 eh o maior
217 14 6217 eh o maior

Solution:

#include <stdio.h>
 
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;
}

2 comments:

  1. in this formula what is the meaning of abs?

    ReplyDelete
    Replies
    1. abs means Absolute value. This function will return the positive value if the given parameter value is negative.

      Delete