Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
xem();
nhap();
kichthuoc();
struct date
{
int ngay;
int thang;
int nam;
};
struct danhsach
{
char hoten[30];
char maso[10];
struct date ngaysinh;
float phucap;
float hsluong;
float tienl;
};
struct danhsach nhansu[50];
main()
{
char menu;
int lap=1;
while(lap)
{
clrscr();
printf("\n 1.nhap du lieu luong");
printf("\n 2.xem danh sach luong");
printf("\n 3.xem kich thuoc cau truc");
printf("\n 4.thoat khoi chuong trinh");
printf("\n go 1/2/3/4 de chon cong viec");
menu= getch();
switch(menu)
{
case '1': nhap();break;
case '2': xem(); break;
case '3': kichthuoc(); break;
case '4': lap=0;break;
default : clrscr();
puts("\n ban chon sai nhan enter de chon lai ");
getch();
break;
}
}
}
nhap()
{
int i,n;
struct danhsach *p;
p=nhansu;
printf("\n ban muon nhap bao nhieu can bo");scanf("%d", &n);
for(i=0;i<n;i++)
{
fflush(stdin);
printf("\n ho ten can bo thu %d : ", i+1); gets(p->hoten);
printf("\n ngay sinh "); scanf("%d", &p->ngaysinh.ngay);
printf("\n thang sinh ");scanf("%d", &p->ngaysinh.thang);
printf("\n nam sinh "); scanf("%d", &p->ngaysinh.nam);
fflush(stdin);
printf("\n ma so ");gets(p->maso);
printf("\n he so luong "); scanf("%f", &p-> hsluong);
printf("\n tien phu cap "); scanf("%f", &p->phucap);
p->tienl=p->hsluong*290000+p->phucap;
p++;
}
puts("\n da nhap xong. enter cai nao");
getch();
}
xem(void)
{
int i,n,m;
struct danhsach *p;
p=nhansu;
printf("\n xem tu so: ");scanf("%d",&m);
printf("\n den so: "); scanf("%d",&n);
clrscr();
puts("\n DANH SACH LUONG CAN BO ");
for (i=m-1;i<n; i++)
{
printf("\n %d- %30s:",i+1,nhansu[i].hoten);
printf("%2d- %2d -%4d", (*(p+i)).ngaysinh.ngay,
(*(p+i)).ngaysinh.thang,(*(p+i)).ngaysinh.nam);
printf("%7s", (*(p+i)).maso);
printf("%5.2f", (p+i)->hsluong);
printf("%6.0f", (p+i)->phucap);
printf("%10.2f",(p+i)->tienl);
}
puts("\n xem xong rui nhan enter de quay ve ");
getch();
return 0;
}
kichthuoc()
{
int kt;
clrscr();
kt= sizeof(struct danhsach);
printf("\n kich thuoc kieu cau truc =%d byte", kt);
getch();
return 0;
}