HKI - LTCB Tuần 9
Bài 1:
Bài 2:
Bài 3:
/*
Ten: Hoang Minh Tuan
Lop: GS19TH1
*/
#include<stdio.h>
#include<string.h>
#define max 100
typedef struct NhanVien{
char ten[32], maso[32], xeploai[32];
int soluong;
float luong;
};
void nhap(NhanVien &b);
void nhapmang(NhanVien a[], int &n);
void xuat(NhanVien b);
void xepl(NhanVien &b);
float tluong(NhanVien &b);
void xuatmang(NhanVien a[], int &n);
void tongtbluong(NhanVien a[], int &n);
void timten(NhanVien a[], int &n);
void timslsp(NhanVien a[], int &n);
void xapxep(NhanVien a[], int &n);
int main(){
NhanVien a[max], b; int n;
printf("============================= NHAP DANH SACH ======================\n"); nhapmang(a,n);
printf("============================= XUAT DANH SACH ======================\n"); xuatmang(a,n);
printf("============================= TB LUONG N_VIEN ======================\n"); tongtbluong(a,n);
printf("\n\n=========================== TIM KIEM TEN NHAN VIEN ===================\n"); timten(a,n);
printf("\n\n=========================== TIM KIEM SLSP NHAN VIEN ====================\n"); timslsp(a,n);
printf("\n\n=========================== XAP XEP NHAN VIEN ====================\n");
xapxep(a,n);
xuatmang(a,n);
return 0;
}
void nhap(NhanVien &b){
printf("Nhap Ten Nhan Vien: "); fflush(stdin); gets(b.ten);
printf("Nhap Ma So Nhan Vien: "); fflush(stdin); gets(b.maso);
printf("Nhap So San Pham Ban Duoc: "); scanf("%i", &b.soluong);
}
void nhapmang(NhanVien a[], int &n){
printf("So Luong Nhan Vien: "); scanf("%i", &n);
for(int i=0;i<n;i++){
printf("\nNhan Vien [ %i ]\n", i+1);
nhap(a[i]);
}
}
void xuat(NhanVien b){
printf("Ten Nhan Vien: "); puts(b.ten);
printf("Ma So Nhan Vien: "); puts(b.maso);
printf("So San Pham Ban Duoc: %i", b.soluong);
}
void xepl(NhanVien &b){
if(b.soluong >= 100){
strcpy(b.xeploai,"Xuat Sac");
printf("%s", b.xeploai);
}
else if(b.soluong >= 80 && b.soluong>=99){
strcpy(b.xeploai,"Tot");
printf("%s", b.xeploai);
}
else if(b.soluong>=60 && b.soluong <=79){
strcpy(b.xeploai,"Dat");
printf("%s", b.xeploai);
}
else if(b.soluong<60){
strcpy(b.xeploai,"Chua Dat");
printf("%s", b.xeploai);
}
}
float tluong(NhanVien &b){
b.luong= b.soluong * 10000;
return b.luong;
}
void xuatmang(NhanVien a[], int &n){
for(int i=0;i<n;i++){
printf("\nNhan Vien [%i]\n", i+1);
xuat(a[i]);
printf("\nXep Loai: "); xepl(a[i]);
printf("\nTien luong cua nhan vien: %.0f VND", tluong(a[i]));
printf("\n");
}
}
void tongtbluong(NhanVien a[], int &n){
float t= 0;
for(int i=0;i<n;i++){
t+= a[i].luong;
}
float tb;
tb= t/n;
printf("Trung Binh Luong= %.2f VND", tb);
}
void timten(NhanVien a[], int &n){
char x[32];
printf("Nhap Ten Nhan Vien Can Tim: "); fflush(stdin); gets(x);
for(int i=0;i<n;i++){
if(strcmp(a[i].ten,x) == 0)
xuat(a[i]);
}
}
void timslsp(NhanVien a[], int &n){
char q;
printf("Nhap SLSP Cua Nhan Vien: "); scanf("%i", &q);
for(int i=0;i<n;i++){
if(a[i].soluong == q)
xuat(a[i]);
}
}
void xapxep(NhanVien a[], int &n){
NhanVien t;
for(int i=0;i<n-1;i++){
for(int j=i+1; j<n;j++){
if(strcmp(a[i].ten,a[j].ten) > 0){
t= a[i];
a[i]= a[j];
a[j]= t;
}
}
}
}
/*
Ten: Hoang Minh Tuan
Lop: GS19TH1
*/
#include<stdio.h>
#include<conio.h>
#define max 100
typedef struct HinhVuong{
float canh, chuvi, dientich;
};
void nhap(HinhVuong &b);
void nhapmang(HinhVuong a[], int &n);
float chuv(HinhVuong &b);
float dient(HinhVuong &b);
void xuat(HinhVuong b);
void xuatmang(HinhVuong a[], int &n);
void tongcv(HinhVuong a[], int &n);
void tbcong(HinhVuong a[], int &n);
int main(){
HinhVuong a[max], b; int n;
printf("=============================== NHAP DANH SACH HV ======================\n"); nhapmang(a,n);
printf("=============================== XUAT DANH SACH HV ======================\n"); xuatmang(a,n);
printf("=============================== TONG CHU VI HV ======================\n"); tongcv(a,n);
printf("\n========================== TB DIEN TICH VI HV ==================\n"); tbcong(a,n);
printf("\n\n\n ========================== END ==================\n");
printf(" By Hoang Minh Tuan \n");
getch();
return 0;
}
void nhap(HinhVuong &b){
printf("Nhap Canh= "); scanf("%f", &b.canh);
}
void nhapmang(HinhVuong a[], int &n){
printf("So Luong Hinh Vuong Can Nhap: "); scanf("%i", &n);
for(int i=0;i<n;i++){
printf("Hinh Vuong Thu [%i]\n", i+1);
nhap(a[i]);
printf("\n");
}
}
float chuv(HinhVuong &b){
b.chuvi= (b.canh * 4);
return b.chuvi;
}
float dient(HinhVuong &b){
b.dientich= b.canh * 2;
return b.dientich;
}
void xuat(HinhVuong b){
printf("Canh= %.2f", b.canh);
}
void xuatmang(HinhVuong a[], int &n){
for(int i=0;i<n;i++){
printf("Hinh Vuong Thu [%i]\n", i+1);
xuat(a[i]);
chuv(a[i]);
printf("\nChu Vi= %.2f", chuv(a[i]));
dient(a[i]);
printf("\nDien Tich= %.2f", dient(a[i]));
printf("\n\n");
}
}
void tongcv(HinhVuong a[], int &n){
float t= 0;
for(int i=0;i<n;i++){
t+= a[i].chuvi;
}
printf("Tong Chu Vi= %.2f", t);
}
void tbcong(HinhVuong a[], int &n){
float tbc= 0;
for(int i=0;i<n;i++){
tbc+= a[i].dientich;
}
float ttb;
ttb= tbc/n;
printf("TB Cong Dien Tich HV= %.2f", ttb);
}
/*
Ten: Hoang Minh Tuan
Lop: GS19TH1
*/
#include<stdio.h>
#include<conio.h>
#define max 100
typedef struct ChuNhat{
float dai, rong, chuvi, dientich;
};
void nhap(ChuNhat &b);
void xuat(ChuNhat b);
void nhapmang(ChuNhat a[], int &n);
float chuv(ChuNhat &b);
float dient(ChuNhat &b);
void xuatmang(ChuNhat a[], int n);
void kiemtra(ChuNhat a[], int &n);
void xapxep(ChuNhat a[], int &n);
int main(){
ChuNhat a[max], b; int n;
printf("==================== NHAP HCN ===================\n"); nhapmang(a,n);
printf("==================== XUAT HCN ===================\n"); xuatmang(a,n);
printf("===================== DT = CV ===============\n"); kiemtra(a,n);
printf("==================== XUAT HCN ===================\n"); xapxep(a,n); xuatmang(a,n);
getch();
return 0;
}
void nhap(ChuNhat &b){
printf("Chieu Dai= "); scanf("%f", &b.dai);
printf("Chieu Rong= "); scanf("%f", &b.rong);
}
void xuat(ChuNhat b){
printf("Dai= %.2f", b.dai);
printf("\nRong= %.2f", b.rong);
}
void nhapmang(ChuNhat a[], int &n){
printf("Nhap Bao Nhieu Hinh Chu Nhat: "); scanf("%i", &n);
for(int i=0;i<n;i++){
printf("Hinh Chu Nhat Thu [%i]\n", i+1);
nhap(a[i]);
printf("\n");
}
}
float chuv(ChuNhat &b){
b.chuvi= (b.dai + b.rong) * 2;
return b.chuvi;
}
float dient(ChuNhat &b){
b.dientich= b.dai * b.rong;
return b.dientich;
}
void xuatmang(ChuNhat a[], int n){
for(int i=0;i<n;i++){
printf("Hinh Chu Nhat Thu [%i]\n", i+1);
xuat(a[i]);
printf("\nChu Vi= %.2f", chuv(a[i]));
printf("\nDien Tich= %.2f", dient(a[i]));
printf("\n\n");
}
}
void kiemtra(ChuNhat a[], int &n){
printf("Thong Tin: \n");
for(int i=0;i<n;i++){
if(a[i].chuvi == a[i].dientich)
xuat(a[i]);
}
}
void xapxep(ChuNhat a[], int &n){
ChuNhat t;
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
if(a[i].dientich > a[j].dientich){
t= a[i];
a[i]= a[j];
a[j]= t;
}
}
}
}
No Comment to " HKI - LTCB Tuần 9 "