URI Online Judge | 1013 The Greatest (Solution)

Problem Link:
https://www.urionlinejudge.com.br/judge/en/problems/view/1013

URI Online Judge | 1013

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,ab,abc;
scanf("%d %d %d",&a,&b,&c);
ab=(a+b+abs(a-b))/2;
abc=(ab+c+abs(ab-c))/2;
printf("%d eh o maior\n",abc);
return 0;
}

Comments

  1. The abs function returns the absolute value of a number (makes it positive) as an integer.

    ReplyDelete
  2. what is abc and how its comes abc=....?

    ReplyDelete
  3. i can not take more than 10 digit... if i take it will wrong. plz fix it...

    ReplyDelete
  4. how i can compile this program in java because it could not recognised abs

    ReplyDelete
  5. how i can compile this program in java because it could not recognised abs

    ReplyDelete
  6. isso parece não funcionar muito bem, com os valores 1,2,3 retorna 3 eh o maior, mas se digitar 1,3,2 retorna que 2 eh o maior... algo de errado no código ? não deveria ser 3 independente da ordem ?

    ReplyDelete

Post a Comment

Popular posts from this blog

URI Online Judge | 1036 Bhaskara's Formula (Solution)

URI Online Judge | 1043 Triangle (Solution)

URI Online Judge | 1042 Simple Sort (Solution)