Em bị lỗi như thế này là sao ạ!?
Đây là code của em: http://codepad.org/YvCs6NZw
#include<iostream>
#include<string.h>
using namespace std;
struct score{
float diemToan;
float diemLy;
float diemHoa;
float tongDiem;
};
struct thiSinh{
string so_bao_danh;
string ho_ten;
string dia_chi;
string gioi_tinh;
score diem;
int phong_thi;
};
//void inPut(thiSinh *a);
//void outPut(thiSinh *a);
//void sumScore(thiSinh *a);
//void menu(thiSinh *ds[], int n);
//void menuPhu(thiSinh *ds[],thiSinh *a,int n);
void inPut(thiSinh *a){
cout<<"\nNhap ten thi sinh: ";
fflush(stdin);
getline(cin,(a->ho_ten));
cout<<"\nNhap gioi tinh: ";
fflush(stdin);
getline(cin,(a->gioi_tinh));
cout<<"\nNhap so bao danh: ";
fflush(stdin);
getline(cin,(a->so_bao_danh));
cout<<"\nNhap ho khau (xa/huyen/tinh): ";
fflush(stdin);
getline(cin,(a->dia_chi));
cout<<"Nhap diem toan: ";
cin>>(a->diem.diemToan);
cout<<"Nhap diem ly: ";
cin>>(a->diem.diemLy);
cout<<"Nhap diem hoa: ";
cin>>(a->diem.diemHoa);
cout<<"Nhap so phong: ";
cin>>(a->phong_thi);
}
void sumScore(thiSinh *a){
a->diem.tongDiem = (a->diem.diemHoa)+(a->diem.diemLy)+(a->diem.diemToan);
}
void outPut(thiSinh *a){
cout<<a->so_bao_danh<<", ";
cout<<a->ho_ten<<", ";
cout<<a->gioi_tinh<<", ";
cout<<"Phong thi: "<<a->phong_thi<<", ";
cout<<"Diem toan: "<<a->diem.diemToan<<", ";
cout<<"Diem ly: "<<a->diem.diemLy<<", ";
cout<<"Diem hoa: "<<a->diem.diemHoa<<", ";
sumScore(a);
cout<<"Diem tong: "<<a->diem.tongDiem<<".";
}
void xapxepTang(thiSinh *ds[], int n){
for(int i = 0; i < n-1; i++){
for(int j = 0; j < n; i++){
if(ds[i]->diem.tongDiem > ds[j]->diem.tongDiem){
float temp = ds[i]->diem.tongDiem;
ds[i]->diem.tongDiem = ds[j]->diem.tongDiem;
ds[j]->diem.tongDiem = temp;
}
}
}
}
void menuPhu(thiSinh *ds[], int n){
int selec1;
system("cls");
cout<<"1.Xuat thong tin theo danh sach da nhap.\n";
cout<<"2.Xuat thong tin theo danh sach phong.\n";
cout<<"3.Xuat thong tin theo thu tu tong diem tang dan.\n";
cout<<"4.Xuat thong tin theo thu tu tong diem giam dan.\n";
cout<<"5.Xuat thong tin theo thu tu tong diem ly tang dan.\n";
cout<<"6.Xuat thong tin theo thu tu tong diem ly giam dan.\n";
cout<<"7.Xuat thong tin theo thu tu tong diem hoa tang dan.\n";
cout<<"9.Xuat thong tin theo thu tu tong diem hoa giam dan.\n";
cout<<"10.Xuat thong tin theo thu tu tong diem toan tang dan.\n";
cout<<"11.Xuat thong tin theo thu tu tong diem toan giam dan.\n";
cout<<"\n=================================================\n";
cout<<"\nNhap lua chon: ";
cin>>selec1;
if(selec1 == 1){
for(int i = 0; i < n; i++){
outPut(ds[n]);
system("pause");
}
}
else
if(selec1 == 2){
xapxepTang(ds,n);
for(int i = 0; i < n; i++){
outPut(ds[n]);
system("pause");
}
}
}
void menu(thiSinh *ds[], int n){
while(true){
system("cls");
cout<<"\n===============================================\n";
cout<<"1.Nhap thong tin thi sinh.\n";
cout<<"2.Xuat thong tin thi sinh.\n";
cout<<"0.Ket thuc.\n";
cout<<"\n===============================================\n";
int selec;
cout<<"Nhap lua chon:\n";
cin>>selec;
if(selec == 0){
break;
}
else
if(selec == 1){
thiSinh *a = new thiSinh;
inPut(a);
ds[n] = a;
n++;
delete a;
}
else
if(selec == 2){
menuPhu(ds,n);
system("pause");
}
}
}
int main(){
thiSinh *ds[200];
thiSinh *a = new thiSinh;
int n = 0;
menu(ds,n);
}
Em cảm ơn!

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?