Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- typedef struct
- {
- char tensach[50];
- char tacgia[30];
- union {
- float USD;
- long VND;
- } gia;
- //int VND; //=1 VND,#1 USD
- float giamgia;
- } sach;
- sach s;
- float thanhtien;
- void thongtinsach(sach s){
- cout << "Ten sach: " << s.tensach << endl;
- cout << "Ten tac gia: " << s.tacgia << endl;
- s.giamgia = float(0.3 * s.gia.VND);
- thanhtien = s.gia.VND - s.giamgia;
- if (thanhtien == 1)
- cout << "Thanh tien: " << thanhtien << " VND" << endl;
- else
- cout << "Thanh tien: " << thanhtien/20.5 << " USD" << endl;
- }
- int main(){
- cout << "Nhap ten sach: " << endl;
- cin.getline(s.tensach, 50);
- cout << "nhap ten tac gia: " << endl;
- cin.getline(s.tacgia, 30);
- cout << "Nhap gia sach: " << endl;
- cin >> s.gia.VND;
- thongtinsach(s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement