Xem giúp e với đoạn tính điểm max và min của e chỗ nào sai ạ mà nó toàn in ra bằng 0
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
struct SinhVien{
char ten[30];
int age;
float dT;
};
typedef SinhVien SV;
void nhapN(SV a[], int n);
void xuat(SV sv);
void xuatN(SV a[], int n);
void xeploai(SV a);
void xeploaiN(SV a[], int n);
int main(){
int key;
char fileName[] = "DSSV.txt";
int n;
bool daNhap = false;
do{
printf("\nBam phim bat ki de vao Chuong Trinh Quan Ly Sinh Vien: "); scanf("%d", &n);
}while(n <= 0);
SV a[n];
while(true){
system("cls");
printf(" ******************************************\n");
printf(" ** CHUONG TRINH QUAN LY SINH VIEN **\n");
printf(" ** 1. Nhap du lieu **\n");
printf(" ** 2. In danh sach sinh vien **\n");
printf(" ** 3. Diem Cao Nhat Mon **\n");
printf(" ** 0. Thoat **\n");
printf(" ******************************************\n");
printf(" ** Nhap lua chon cua ban **\n");
printf(" ******************************************\n");
scanf("%d",&key);
switch(key){
case 1:
printf("Nhap bao nhieu sinh vien? ");
scanf("%d",&n);
nhapN(a, n);
printf("\nBan da nhap thanh cong!");
daNhap = true;
printf("\nBam phim bat ky de tiep tuc!");
getch();
break;
case 2:
if(daNhap){
printf("\nBan da chon xuat DS sinh vien!");
xuatN(a, n);
}else{
printf("\nNhap DS SV truoc!!!!");
}
printf("\nBam phim bat ky de tiep tuc!");
getch();
break;
case 3:
if(daNhap){
printf("\nBan da chon Xem Diem Cao Nhat Mon!");
xeploaiN(a, n);
}else{
printf("\nNhap DS SV truoc!!!!");
}
printf("\nBam phim bat ky de tiep tuc!");
getch();
break;
case 0:
printf("\nBan da chon thoat chuong trinh!");
getch();
return 0;
default:
printf("\nKhong co chuc nang nay!");
printf("\nBam phim bat ky de tiep tuc!");
getch();
break;
}
}
}
void nhap(SV &sv){
printf("\nNhap Ho va ten: "); fflush(stdin); gets(sv.ten);
printf("\nNhap ID sinh vien: "); scanf("%d", &sv.age);
printf("\nNhap Diem mon toan : "); scanf("%f", &sv.dT);
}
void nhapN(SV a[], int n){
printf("\n____________________________________\n");
for(int i = 0; i< n; ++i){
printf("\nNhap SV thu %d:", i+1);
nhap(a[i]);
}
printf("\n____________________________________\n");
}
void xuat(SV sv){
printf("\nHo ten SV: %s", sv.ten);
printf("\nID SV : %d", sv.age);
printf("\nDiem Toan : %f ", sv.dT);
}
void xuatN(SV a[], int n){
printf("\n____________________________________\n");
for(int i = 0;i < n;++i){
printf("\nThong tin SV thu %d:", i+1);
xuat(a[i]);
}
printf("\n____________________________________\n");
}
void xeploai(SV sv)
{
float min=0;
for(int i = 0 ; i < sv.dT ; ++i)
if(sv.dT>min)
min=sv.dT;
printf("\nSV %d co diem toan thap nhat: %f",min);
}
void xeploaiN(SV a[], int n){
float max = 10;
for(int i = 0 ; i<n ; ++i){
if(a[i].dT>max)
max=a[i].dT;
}
printf("\n____________________________________\n");
printf("\nSV %d co diem toan cao nhat : %f",max);
}