Check all possible operations between the numbers , and . If the value of the resulting expression equals , print this expression. Otherwise, print the word CORONA.
Algorithm implementation
Read the input data.
scanf("%d %d %d", &a, &b, &c);Iterate over all possible operations between the numbers. Depending on the result, print the appropriate answer.
if (a + b + c == 2020) printf("%d+%d+%d", a, b, c); else
if (a + b - c == 2020) printf("%d+%d-%d", a, b, c); else
if (a - b + c == 2020) printf("%d-%d+%d", a, b, c); else
if (a - b - c == 2020) printf("%d-%d-%d", a, b, c); else
printf("CORONA\n");Python implementation
Read the input data.
a, b, c = map(int, input().split())Iterate over all possible operations between the numbers. Depending on the result, print the appropriate answer.
if a + b + c == 2020:
print(f"{a}+{b}+{c}")
elif a + b - c == 2020:
print(f"{a}+{b}-{c}")
elif a - b + c == 2020:
print(f"{a}-{b}+{c}")
elif a - b - c == 2020:
print(f"{a}-{b}-{c}")
else:
print("CORONA")