Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.0 kB
0
Indexable
Never
#include <stdio.h>
#include <malloc.h>

struct ThongTinSV{
	int ID;
	char Name[10];
	float DiemQT, DiemCK;
	char XepLoai;
};

char HamXepLoai(float qt, float ck){
	float tk = qt * 0.4 + ck * 0.6; 
	char xep_loai = 'F';
	if (tk >= 8.5){
		xep_loai = 'A';
	} else if (tk >= 7){
		xep_loai = 'B';
	} else if (tk >= 6.5){
		xep_loai = 'C';
	}
	return xep_loai;
}

int main(){
	struct ThongTinSV DSAI01[3];

	int i;
	for (i = 0; i < 3; i++){
		printf("Ten SV %d: ", i); 
		fflush(stdin);
		gets(DSAI01[i].Name);

		printf("MSSV %d: ", i);
		scanf("%d", &DSAI01[i].ID);

		printf("Diem QT %d: ", i);
		scanf("%f", &DSAI01[i].DiemQT);

		printf("Diem CK %d: ", i);
		scanf("%f", &DSAI01[i].DiemCK);
		// printf("/")
		DSAI01[i].XepLoai = HamXepLoai(DSAI01[i].DiemQT, DSAI01[i].DiemCK);
	}
	// printf("ID\tTenSV\tDiem ")
	for (i = 0; i < 3; i++){

		printf("%d\t%s\t%f\t%f\t%c\n", DSAI01[i].ID, DSAI01[i].Name, DSAI01[i].DiemQT, DSAI01[i].DiemCK, DSAI01[i].XepLoai);
	}
	return 0;
}