#t5. 计算两个数的和差积商

计算两个数的和差积商

Sum, Difference, Product and Quotient

Problem Description

Read two non-negative integers aa and bb (with b≠0b \neq 0 guaranteed), and compute and output their sum, difference, product, and quotient respectively.

This problem uses only the four basic arithmetic operations; you can finish it without any conditional (if) statements.

Input Format

One line containing two non-negative integers aa and bb, separated by a single space. b≠0b \neq 0 is guaranteed.

Output Format

Print four lines in the following format (replace the bracketed parts with the actual values):

[a] + [b] = [a+b]
[a] - [b] = [a-b]
[a] * [b] = [a*b]
[a] / [b] = [a/b]

where:

  • The first three lines (sum, difference, product) are integers; print them directly. Note that a−ba - b may be negative — just print it directly, the minus sign comes automatically.
  • The fourth line (quotient) must be printed with exactly two decimal places.

Sample Input 1

10 2

Sample Output 1

10 + 2 = 12
10 - 2 = 8
10 * 2 = 20
10 / 2 = 5.00

Sample Input 2

10 3

Sample Output 2

10 + 3 = 13
10 - 3 = 7
10 * 3 = 30
10 / 3 = 3.33

Constraints

0≤a,b≤1000 \le a, b \le 100, and b≠0b \neq 0.

Hint

  • Each equation line must be printed with cout, concatenating the number, the operator, and the spaces exactly as in the sample.
  • The fourth line is the trap of this problem: writing a / b between two int values does integer division and drops the fractional part. Find a way to make the division produce a decimal result.
  • Keeping two decimal places requires format controls — look up fixed and setprecision (in the <iomanip> header).
  • Check against sample 1: 10 / 2 should output 5.00, not 5.