This commit is contained in:
tienthieusac
2018-10-03 20:45:35 +07:00
committed by Minh Tien Nguyen
commit b0111fce8a
25 changed files with 2196 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
#include <iostream>
#include <iomanip>
using namespace std;
class candidate
{
public:
int id;
char* name;
private:
float math, physics, chemistry;
public:
candidate(int id, char* name, float math, float physics, float chemistry)
{
this->id = id;
this->name = name;
this->math = math;
this->physics = physics;
this->chemistry = chemistry;
}
~candidate()
{
id = 0;
delete[] name;
name = NULL;
math = 0;
physics = 0;
chemistry = 0;
}
float total_grade()
{
return (math + physics + chemistry);
}
};
int main()
{
candidate *t;
float tongdiem;
int id;
char *name = new char[256];
float math, physics, chemistry;
cout << "Nhap id: " << endl;
cin >> id;
cout << "Nhap ten: " << endl;
cin.clear();
cin.ignore(999, '\n');
cin.getline(name, 256);
cout << "Nhap diem Toan: " << endl;
cin >> math;
cout << "Nhap diem Ly: " << endl;
cin >> physics;
cout << "Nhap diem Hoa: " << endl;
cin >> chemistry;
t = new candidate(id, name, math, physics, chemistry);
tongdiem = t->total_grade();
cout << "Tong diem: " << setprecision(4) << tongdiem << endl;
delete t;
t = NULL;
system("pause");
return 0;
}