URI Online Judge | 1013
The Greatest
Adapted by Neilor Tonin, URI  Brazil
 Brazil
Timelimit: 1 Brazil
 Brazil
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 Samples | Output Samples | 
| 7 14 106 | 106 eh o maior | 
| 217 14 6 | 217 eh o maior | 
URI Online Judge Solution 1013 || The Greatest in C language
#include<stdio.h>#include<math.h>int main(){    int a, b, c, maxab, max;    scanf("%d %d %d", &a, &b, &c);    maxab = ((a + b + abs(a - b)) / 2);    max =  ((maxab + c + abs(maxab - c)) / 2);    printf("%d eh o maior\n", max);    return 0;}
You don't even need this formula. Use
ReplyDelete#include
using namespace std;
int main() {
int A,B,C,big;
cin >> A >> B >> C;
if(A>B && A>C){
big = A;
}
else if(B>C){
big = B;
}
else{
big = C;
}
cout << big << " eh o maior " <<endl;
return 0;
}
your ans I think correct but i can't ensure you. Because this formula I used already but its doesn't make any sense
Delete#include
ReplyDeleteint main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a>b && a>c)
{
printf("%d\n eh o maior",a);
}
else if
(b>a && b>c)
{
printf("%d\n eh o maior",b);
}
else if(c>a && c>b)
{
printf("%d\n eh o maior",c);
}
return 0;
}