Algorithm/CodeUp
1205 : 최댓값
B2SIC
2019. 4. 28. 23:35
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <stdio.h> int main() { double a, b; double maxValue = 0; double powTmp = 1; scanf("%lf %lf", &a, &b); if (a + b > maxValue) maxValue = a + b; if (a - b > maxValue) maxValue = a - b; if (b - a > maxValue) maxValue = b - a; if (a * b > maxValue) maxValue = a * b; if (a / b > maxValue) maxValue = a / b; if (b / a > maxValue) maxValue = b / a; for(int i = 1; i <= b; i++) powTmp *= a; if (powTmp > maxValue) maxValue = powTmp; powTmp = 1; for(int k = 1; k <= a; k++) powTmp *= b; if (powTmp > maxValue) maxValue = powTmp; printf("%.6f", maxValue); return 0; } | cs |