Gửi bài giải
Điểm:
100,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Biểu thức
In ra tổng, tích, hiệu và thương của 2 số được nhập vào từ bàn phím. Kết quả lấy 3 chữ số sau dấu phẩy.
Input
Hai số thực a, b
Output
4 giá trị tổng, hiệu, tích, thương (a/b) của hai số a và b, mỗi giá trị trên 1 dòng
Ví dụ:
Input
1 2
Output
3.000
-1.000
2.000
0.500
Bình luận
include <iostream>
include <iomanip>
int main() { double a, b; std::cin >> a >> b; double sum = a + b; double difference = a - b; double product = a * b; double quotient = a / b; std::cout << std::fixed << std::setprecision(3) << sum << std::endl; std::cout << std::fixed << std::setprecision(3) << difference << std::endl; std::cout << std::fixed << std::setprecision(3) << product << std::endl; std::cout << std::fixed << std::setprecision(3) << quotient << std::endl; return 0; }