URI - BEECROWD - BEE Online Judge Solution 1013 | The Greatest - URI - BEECROWD - BEE 1013 Solution in C,C++,Python
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
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 |
URI Online Judge Solution 1013 | The Greatest - URI 1013 Solution in C,C++,Python ::
URI Problem 1013 Solution in C :
URI Online Judge 1013 Solve in C : #include <stdio.h>
int main() { int a, b, c, tmp; scanf("%d %d %d", &a, &b, &c); tmp = a; if(a < b || a < c){ if(b < c){ tmp = c; } else{ tmp = b; } } printf("%d eh o maior\n", tmp); return 0; } |
URI Problem 1013 Solution in C ++:
URI Online Judge 1013 Solve in C++ : #include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,MaiorAB,s,MAX; cin>>a>>b>>c; MaiorAB=(a+b+abs(a-b))/2; MAX=(MaiorAB+c+abs(MaiorAB-c))/2; cout<< MAX<<" eh o maior"<<endl; return 0; }
|
URI Problem 1013 Solution in Python:
URI Online Judge 1013 Solve in Python : import math
valor = input().split(" ") a, b, c = valor
maior = (int(a) + int(b) + abs(int(a) - int(b))) / 2 resultado = (int(maior) + int(c) + abs(int(maior) - int(c)))/2
print("%d eh o maior" %resultado)
|
Previous Post:
Thank You
ReplyDeletewelcome
ReplyDeleteThank You Sir
ReplyDeletevalo onek
ReplyDeletewelcome
ReplyDeletewhat is abs() and what does it do?
ReplyDeleteabs(5) returns 5 because the absolute value of 5 is 5, and abs(-5) returns 5 as well because the absolute value of -5 is also 5.
ReplyDelete