Noname.CPP
02-02-2009, 10:06 AM
Có bác nào pro xem giúp em cái bài SV này em sai ở đâu thế ????
Nó cứ báo lỗi ngay getch() quài =.=!
// SV.cpp : Defines the entry point for the console application.
// -[]- Noname.CPP -[]-
#include "iostream.h"
#include "conio.h"
#include "stdio.h"
class student
{
private:
int n;
char ho_ten[20];
char dia_chi[30];
int nam_sinh;
float toan,ly,hoa;
public:
void nhap();
void xuat();
void DTB();
void SV_co_DTB_tren_5();
};
//__________________
void student::nhap()
{
cout<<"\n Nhap SV: ";
cin>>ho_ten;
cout<<"\n Nhap dia chi: ";
cin>>dia_chi;
cout<<"\n Nhap nam sinh: ";
cin>>nam_sinh;
cout<<"\n Nhap diem toan: ";
cin>>toan;
cout<<"\n Nhap diem ly: ";
cin>>ly;
cout<<"\n Nhap diem hoa: ";
cin>>hoa;
DTB=(toan+ly+hoa)/3;
void student::xuat()
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n dia chi: "<<dia_chi;
cout<<"\n nam sinh: "<<nam_sinh;
cout<<"\n diem toan: "<<toan;
cout<<"\n diem ly: "<<ly;
cout<<"\n diem hoa: "<<hoa;
cout<<"\n Diem trung binh: "<<DTB;
cout<<"\n\n";
};
void SV_co_DTB_tren_5()
{
if(DTB > 5)
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n DTB: "<<DTB;
}
else
cout<<"\n Khong co sinh vien nao";
}
void main()
{
clrscr();
int n;
cout<<"\n Nhap vao so SV: ";
cin>>n;
cout<<"\n";
student sv[100];
for(int i=1;i<n;i++)
sv[i].nhap();
cout<<"\n";
for(int i=1;i<n;i++)
sv[i].xuat();
cout<<"\n\n-------------TONG KET--------------";
cout<<"\n\n THONG KE SINH VIEN CO DIEM TRUNG BINH > 5";
for(int i=1;i<n;i++)
sv.[i].DTB();
getch();
}
Nó cứ báo lỗi ngay getch() quài =.=!
// SV.cpp : Defines the entry point for the console application.
// -[]- Noname.CPP -[]-
#include "iostream.h"
#include "conio.h"
#include "stdio.h"
class student
{
private:
int n;
char ho_ten[20];
char dia_chi[30];
int nam_sinh;
float toan,ly,hoa;
public:
void nhap();
void xuat();
void DTB();
void SV_co_DTB_tren_5();
};
//__________________
void student::nhap()
{
cout<<"\n Nhap SV: ";
cin>>ho_ten;
cout<<"\n Nhap dia chi: ";
cin>>dia_chi;
cout<<"\n Nhap nam sinh: ";
cin>>nam_sinh;
cout<<"\n Nhap diem toan: ";
cin>>toan;
cout<<"\n Nhap diem ly: ";
cin>>ly;
cout<<"\n Nhap diem hoa: ";
cin>>hoa;
DTB=(toan+ly+hoa)/3;
void student::xuat()
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n dia chi: "<<dia_chi;
cout<<"\n nam sinh: "<<nam_sinh;
cout<<"\n diem toan: "<<toan;
cout<<"\n diem ly: "<<ly;
cout<<"\n diem hoa: "<<hoa;
cout<<"\n Diem trung binh: "<<DTB;
cout<<"\n\n";
};
void SV_co_DTB_tren_5()
{
if(DTB > 5)
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n DTB: "<<DTB;
}
else
cout<<"\n Khong co sinh vien nao";
}
void main()
{
clrscr();
int n;
cout<<"\n Nhap vao so SV: ";
cin>>n;
cout<<"\n";
student sv[100];
for(int i=1;i<n;i++)
sv[i].nhap();
cout<<"\n";
for(int i=1;i<n;i++)
sv[i].xuat();
cout<<"\n\n-------------TONG KET--------------";
cout<<"\n\n THONG KE SINH VIEN CO DIEM TRUNG BINH > 5";
for(int i=1;i<n;i++)
sv.[i].DTB();
getch();
}