Advertisement
pdaogu

Ex6.4

Oct 14th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define P_TU_LANH 8
  4. #define P_TV 15
  5. #define P_LAPTOP 12
  6. #define DON_VI 1000000
  7.  
  8. int main () {
  9.     int tu_lanh, tv, laptop, ds_tu_lanh, ds_tv, ds_laptop;
  10.     int total;
  11.     printf("%*s%s%*s\n\n", 10, "","SIEU THI VIET LONG", 10, "");
  12.     printf("> Nhap vao so luong san pham da ban: \n");
  13.     printf("\t+ Tu lanh Electronux: ");
  14.     scanf("%d", &tu_lanh);
  15.     printf("\t+ TV LCD Sony: ");
  16.     scanf("%d", &tv);
  17.     printf("\t+ Laptop HP: ");
  18.     scanf("%d", &laptop);
  19.     total = tu_lanh*P_TU_LANH + tv*P_TV + laptop*P_LAPTOP;
  20.     printf("\n> Doanh so ban hang cua sieu thi: \n");
  21.     printf("---------------------------------------------------------------------------------\n");
  22.     printf("|%-*s%-*s%-*s%-*s%-*s|\n", 5, "STT", 25, "TEN SAN PHAM", 12, "SO LUONG", 17, "DON GIA (VND)", 20, "THANH TIEN (VND)");
  23.     printf("|-------------------------------------------------------------------------------|\n");
  24.     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);
  25.     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);
  26.     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);
  27.     printf("|%*s%s%-*d|\n", 53, "", "Tong: ", 20, total * DON_VI);
  28.     printf("---------------------------------------------------------------------------------\n\n");
  29.     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"));
  30.     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"));
  31.     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"));
  32.     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"));
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement