URI Online Judge | 1013 The Greatest (Solution)
Problem Link:
https://www.urionlinejudge.com.br/judge/en/problems/view/1013
Solution:
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 Inputs | Sample Outputs |
7 14 106 | 106 eh o maior |
217 14 6 | 217 eh o maior |
#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;
}
what is abs?
ReplyDeleteits work as modules
DeleteThe abs function returns the absolute value of a number (makes it positive) as an integer.
ReplyDeleteThanks
Deletewhat is abc and how its comes abc=....?
ReplyDeletei can not take more than 10 digit... if i take it will wrong. plz fix it...
ReplyDeletehow i can compile this program in java because it could not recognised abs
ReplyDeleteuse Math.abs
Deletehow i can compile this program in java because it could not recognised abs
ReplyDeleteuse Math.abs
Deleteisso 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