Thursday, May 26, 2016

URI Online Judge Solution 1013 || The Greatest



URI Online Judge | 1013

The Greatest

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
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


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;
}







3 comments:
Write comments
  1. You don't even need this formula. Use

    #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;
    }

    ReplyDelete
    Replies
    1. 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
  2. #include
    int 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;
    }

    ReplyDelete

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.