Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bài 3: Nhắc người dùng chọn 1 tùy chọn. Nhắc họ nhập vào 2 số nguyên và in kết quả ứng với tùy chọn đó
- #include <iostream>
- using namespace std;
- int x, y;
- void Tong();
- void Hieu();
- int main()
- {
- int chon;
- cout << "Lua chon 1 trong 2 tuy chon sau" << endl;
- cout << "1. Tinh tong hai so" << endl;
- cout << "2. Tinh hieu hai so" << endl;
- cout << "Lua chon cua ban: ";
- cin >> chon;
- if (chon = 1) {
- Tong();
- }
- if (chon = 2) {
- Hieu();
- }
- system("pause");
- return 0;
- }
- void Tong()
- {
- cout << "Nhap x: ";
- cin >> x;
- cout << "Nhap y: ";
- cin >> y;
- int t;
- t = x + y;
- cout << "Tong cua " << x << " va " << y << " la " << t << endl;
- }
- void Hieu()
- {
- cout << "Nhap x: ";
- cin >> x;
- cout << "Nhap y: ";
- cin >> y;
- int h;
- h = x - y;
- cout << "Hieu cua " << x << " va " << y << " la " << h << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement