cautruc
#include<stdio.h>
#include<conio.h>
#include<string.h>
typedef struct{
char hoten[20];
char qq[30];
char gioitinh[5];
int tuoi;
int dt,dl,dh,td;
}DSSV;
void nhap(DSSV sv[100],int k,char s[100]){
printf("\%s:
",s);
for(int i=0;i<k;i++)
{
printf("
>> Sinh vien thu:%d",i+1);
printf("
-Ho ten:");
fflush(stdin); //giai phong bo dem catch truoc khi nhap xau
gets(sv[i].hoten);
printf("-Que quan:"); fflush(stdin); gets(sv[i].qq);
printf("-Gioi tinh:"); fflush(stdin); gets(sv[i].gioitinh);
printf("-Tuoi:"); scanf("%d",&sv[i].tuoi);
printf("-Diem toan:"); scanf("%d",&sv[i].dt);
printf("-Diem ly:"); scanf("%d",&sv[i].dl);
printf("-Diem hoa:"); scanf("%d",&sv[i].dh);
sv[i].td=sv[i].dt+sv[i].dl+sv[i].dh;
clrscr();
}
}
void xuat(DSSV sv[100],int k,char s[100]){
printf("
%s
",s);
printf("%18s%12s%10s%8s%8s%8s%8s%8s
","Ho ten","Que quan","Gioi tinh","Tuoi","Toan","Ly","Hoa","Tong");
for(int i=0;i<k;i++)
printf("%18s%12s%10s%8d%8d%8d%8d%8d
",sv[i].hoten,sv[i].qq,sv[i].gioitinh,sv[i].tuoi,sv[i].dt,sv[i].dl,sv[i].dh,sv[i].td);
}
void truot(DSSV sv[100],int k,char s[100]){
printf("
%s
",s);
printf("%18s%12s%10s%8s%8s%8s%8s%8s
","Ho ten","Que quan","Gioi tinh","Tuoi","Toan","Ly","Hoa","Tong");
for(int i=0;i<k;i++)
if(sv[i].td<15||sv[i].dt==0||sv[i].dl==0||sv[i].dh==0)
printf("%18s%12s%10s%8d%8d%8d%8d%8d
",sv[i].hoten,sv[i].qq,sv[i].gioitinh,sv[i].tuoi,sv[i].dt,sv[i].dl,sv[i].dh,sv[i].td);
}
void timkiem(DSSV sv[100],int k,char name[20],char s[100]){
int d=0;
printf("
%s
",s);
printf("%18s%12s%10s%8s%8s%8s%8s%8s
","Ho ten","Que quan","Gioi tinh","Tuoi","Toan","Ly","Hoa","Tong");
for(int i=0;i<k;i++)
if(strcmp(sv[i].hoten,name)==0)
{d++;
printf("%18s%12s%10s%8d%8d%8d%8d%8d
",sv[i].hoten,sv[i].qq,sv[i].gioitinh,sv[i].tuoi,sv[i].dt,sv[i].dl,sv[i].dh,sv[i].td);
}
if(d==0)
printf("Khong co sinh vien co ten:%s
",name);
}
void main(){
DSSV sv[100];
int n;
clrscr();
printf("n="); scanf("%d",&n);
nhap(sv,n,"NHAP DANH SACH SINH VIEN");
xuat(sv,n," DANH SACH SINH VIEN VUA NHAP ");
truot(sv,n," DANH SANCH THI TRUOT ");
char ten[20];
printf("
Moi hap ten can tim:");
fflush(stdin);
scanf("%s",&ten);
timkiem(sv,n,ten," DANH SACH TIM THAY ");
getch();
}
Bạn đang đọc truyện trên: Truyen247.Pro