cslt hien thi danh sach cb
#include<stdio.h>
#include<conio.h>
#define max 100
int n,i;
typedef struct
{
int ngay,thang,nam;
} date;
typedef struct
{
char hoten[30];
char hocvan[30];
date ngaysinh;
int sohieu,madonvi,bacluong;
}canbo;
canbo cb[max];
FILE *fp;
/************************************/
void nhap()
{
fp=fopen("b4dechan.in","wb");
printf("So luong can bo:");scanf("%d*c",&n);
fwrite(&n,sizeof(n),1,fp);
printf("NHAP THONG TIN MOI CAN BO!");
for (i=1;i<=n;++i)
{
fflush(stdin);
printf("
Can bo thu %d",i);
printf("
Ho va ten:");gets(cb[i].hoten);fwrite(&cb[i].hoten,sizeof(cb[i].hoten),1,fp);
printf("
Hoc van:");gets(cb[i].hocvan);fwrite(&cb[i].hocvan,sizeof(cb[i].hocvan),1,fp);
printf("
Ngay sinh:");scanf("%d",&cb[i].ngaysinh.ngay);fwrite(&cb[i].ngaysinh.ngay,sizeof(cb[i].ngaysinh.ngay),1,fp);
printf("
Thang sinh:");scanf("%d",&cb[i].ngaysinh.thang);fwrite(&cb[i].ngaysinh.thang,sizeof(cb[i].ngaysinh.thang),1,fp);
printf("
Nam sinh:");scanf("%d",&cb[i].ngaysinh.nam);fwrite(&cb[i].ngaysinh.nam,sizeof(cb[i].ngaysinh.nam),1,fp);
printf("
So hieu:");scanf("%d",&cb[i].sohieu);fwrite(&cb[i].sohieu,sizeof(cb[i].sohieu),1,fp);
printf("
Ma don vi:");scanf("%d",&cb[i].madonvi);fwrite(&cb[i].madonvi,sizeof(cb[i].madonvi),1,fp);
printf("
Bac luong:");scanf("%d",&cb[i].bacluong);fwrite(&cb[i].bacluong,sizeof(cb[i].bacluong),1,fp);
}
fclose(fp);
}
/**********************************************************/
void hien_thi()
{
int mdv;
printf("
BAN MUON HIEN THI DANH SACH CAN BO CUA DON VI:");scanf("%d",&mdv);fwrite(&mdv,sizeof(mdv),1,fp);
printf("
____________DANH SACH DON VI %d________________ ");
for (i=1;i<=n;++i)
{
if (cb[i].madonvi==mdv) printf("
%s",cb[i].hoten);
printf("
______________________________________________
");
}
}
/**********************************************************/
void main()
{
clrscr();
nhap();
hien_thi();
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top