Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define P_TU_LANH 8
- #define P_TV 15
- #define P_LAPTOP 12
- #define DON_VI 1000000
- int main () {
- int tu_lanh, tv, laptop, ds_tu_lanh, ds_tv, ds_laptop;
- int total;
- printf("%*s%s%*s\n\n", 10, "","SIEU THI VIET LONG", 10, "");
- printf("> Nhap vao so luong san pham da ban: \n");
- printf("\t+ Tu lanh Electronux: ");
- scanf("%d", &tu_lanh);
- printf("\t+ TV LCD Sony: ");
- scanf("%d", &tv);
- printf("\t+ Laptop HP: ");
- scanf("%d", &laptop);
- total = tu_lanh*P_TU_LANH + tv*P_TV + laptop*P_LAPTOP;
- printf("\n> Doanh so ban hang cua sieu thi: \n");
- printf("---------------------------------------------------------------------------------\n");
- printf("|%-*s%-*s%-*s%-*s%-*s|\n", 5, "STT", 25, "TEN SAN PHAM", 12, "SO LUONG", 17, "DON GIA (VND)", 20, "THANH TIEN (VND)");
- printf("|-------------------------------------------------------------------------------|\n");
- printf("|%-*d%-*s%-*d%-*d%-*d|\n", 5, 1, 25, "Tu lanh ELECTRONUX", 12, tu_lanh, 17, P_TU_LANH * DON_VI, 20, ds_tu_lanh = tu_lanh * P_TU_LANH * DON_VI);
- printf("|%-*d%-*s%-*d%-*d%-*d|\n", 5, 2, 25, "TV LCD SONY", 12, tv, 17, P_TV * DON_VI, 20, ds_tv = tv * P_TV * DON_VI);
- printf("|%-*d%-*s%-*d%-*d%-*d|\n", 5, 3, 25, "LAPTOP HP", 12, laptop, 17, P_LAPTOP * DON_VI, 20, ds_laptop = laptop * P_LAPTOP * DON_VI);
- printf("|%*s%s%-*d|\n", 53, "", "Tong: ", 20, total * DON_VI);
- printf("---------------------------------------------------------------------------------\n\n");
- printf("> Mat hang ban chay nhat la: %s\n", tu_lanh > tv ? (tu_lanh > laptop ? "Tu lanh Electronux" : (tv > laptop ? "TV LCD Sony" : "Laptop HP")) : (tv > laptop ? "TV LCD Sony" : "Laptop HP"));
- printf("> Mat hang ban e nhat la: %s\n\n", tu_lanh < tv ? (tu_lanh < laptop ? "Tu lanh Electronux" : (tv < laptop ? "TV LCD Sony" : "Laptop HP")) : (tv < laptop ? "TV LCD Sony" : "Laptop HP"));
- printf("> Mat hang doanh so cao nhat la: %s\n", ds_tu_lanh > ds_tv ? (ds_tu_lanh > ds_laptop ? "Tu lanh Electronux" : (ds_tv > ds_laptop ? "TV LCD Sony" : "Laptop HP")) : (ds_tv > ds_laptop ? "TV LCD Sony" : "Laptop HP"));
- printf("> Mat hang doanh so thap nhat la: %s\n\n", ds_tu_lanh < ds_tv ? (ds_tu_lanh < ds_laptop ? "Tu lanh Electronux" : (ds_tv < ds_laptop ? "TV LCD Sony" : "Laptop HP")) : (ds_tv < ds_laptop ? "TV LCD Sony" : "Laptop HP"));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement