Professional Documents
Culture Documents
Thng tin v Sinh vin gm: M sinh vin, H tn, Ngy sinh, Lp, TB Hc tp, im rn luyn, im Tng kt, v Hc bng. Vit chng trnh thc hin cc chc nng sau: 1.Nhp thm sinh vin Nhp thng tin v sinh vin (khng nhp im tng kt v Hc bng). Trong im rn luyn tnh theo thang 100. Nu im rn luyn t 70 - 80, TK = TB Hc tp + 0,2. Nu im rn luyn t 80 - 90, TK = TB Hc tp + 0,5. Nu im rn luyn t 90 - 100, TK = TB Hc tp + 0,8. Hc bng: Nu TK >=7.0, Hc bng = 120000, TK>=80, Hc bng = 180000, nu TK >=90, Hc bng = 240000. C kim tra m sinh vin khi nhp (khng c hai sinh vin m trng nhau)
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<iomanip.h>
class SinhVien{
private:
char hoTen[50];
int maSV;
char ngaySinh[20];
char lop[20];
float diemTB;
float diemRenLuyen;
float diemTK;
int hocBong;
SinhVien *sv;
int sl;
public:
void nhapSV();
void hienThiSinhVien();
void sapXepTheoDTB();
void sapXepTheoHocBong();
void timTheoTen();
void timTheoDTK();
void ghiFile();
void docFile();
void khoiTaoFile();
SinhVien(){
sl= 0;
sv= NULL;
~SinhVien(){
delete sv;
};
void SinhVien::nhapSV(){
int i= sl+1;
cin.getline(sv[i].hoTen,sizeof(sv[i].hoTen));
int check;
do{
check= 1;
cin>>sv[i].maSV;
for(int j=1;j<i;j++){
if(sv[j].maSV== sv[i].maSV){
check= 0;
}while(check== 0);
cin.ignore();
cin.getline(sv[i].ngaySinh,sizeof(sv[i].ngaySinh));
cin.getline(sv[i].lop,sizeof(sv[i].lop));
cin>>sv[i].diemTB;
cin>>sv[i].diemRenLuyen;
if((sv[i].diemRenLuyen>=70)&&(sv[i].diemRenLuyen<80)){
else if((sv[i].diemRenLuyen>=80)&&(sv[i].diemRenLuyen<90)){
else if((sv[i].diemRenLuyen>=90)&&(sv[i].diemRenLuyen<=100)){
if((sv[i].diemTK>=7)&&(sv[i].diemTK<8)){
sv[i].hocBong= 120000;
else if((sv[i].diemTK>=8)&&(sv[i].diemTK<9)){
sv[i].hocBong= 180000;
else if((sv[i].diemTK>=9)&&(sv[i].diemTK<=10)){
sv[i].hocBong= 240000;
void SinhVien::khoiTaoFile(){
fstream f(dataFile,ios::out|ios::app);
f.close();
void SinhVien::ghiFile(){
fstream os(dataFile,ios::out|ios::app);
int i= sl+1;
os<<sv[i].hoTen<<endl;
os<<sv[i].maSV<<endl;
os<<sv[i].ngaySinh<<endl;
os<<sv[i].lop<<endl;
os<<setw(5)<<sv[i].diemTB
<<setw(5)<<sv[i].diemRenLuyen
<<setw(5)<<sv[i].diemTK
<<setw(10)<<sv[i].hocBong<<endl;
os.close();
void SinhVien::docFile(){
fstream s(dataFile,ios::in);
int dem=1;
string buffer;
while(1){
getline(s,buffer);
if(!s.eof()){
dem++;
else
break;
sl= dem/5;
s.close();
fstream f(dataFile,ios::in);
for(int i=1;i<=sl;i++){
f.getline(sv[i].hoTen,sizeof(sv[i].hoTen));
f>>sv[i].maSV;
f.ignore(1);
f.getline(sv[i].ngaySinh,sizeof(sv[i].ngaySinh));
f.getline(sv[i].lop,sizeof(sv[i].lop));
f>>sv[i].diemTB>>sv[i].diemRenLuyen>>sv[i].diemTK>>sv[i].hocBong;
f.ignore();
f.close();
void SinhVien::hienThiSinhVien(){
cout<<endl;
"<<maSV;
cout<<endl<<"Lop:
"<<lop;
"<<diemTB;
"<<diemRenLuyen;
"<<diemTK;
"<<hocBong;
void SinhVien::sapXepTheoDTB(){
SinhVien s;
for(int i=1;i<=sl;i++){
for(int j=1;j<i;j++){
if(sv[j].diemTB>sv[i].diemTB){
s= sv[i];
sv[i]= sv[j];
sv[j]= s;
for(int i=1;i<=sl;i++){
sv[i].hienThiSinhVien();
void SinhVien::sapXepTheoHocBong(){
SinhVien s;
for(int i=1;i<=sl;i++){
for(int j=1;j<i;j++){
if(sv[j].hocBong>sv[i].hocBong){
s= sv[i];
sv[i]= sv[j];
sv[j]= s;
for(int i=1;i<=sl;i++){
sv[i].hienThiSinhVien();
void SinhVien::timTheoTen(){
char tenSV[20];
char *strKiemTra;
char ten[20];
int count=0;
cin.ignore();
cin.getline(tenSV,sizeof(tenSV));
char *token;
char str[20];
for(int i=1;i<=sl;i++){
strKiemTra= NULL;
//Gan ho ten vao bien str -> cat bien str ko cat ho ten
strcpy(str,sv[i].hoTen);
while(token!=NULL){
strcpy(ten,token);
if(strKiemTra!= NULL){
sv[i].hienThiSinhVien();
count++;
void SinhVien::timTheoDTK(){
int diemTimKiem;
int count=0;
cin>>diemTimKiem;
cout<<endl<<"Cac sinh vien co diem tong ket >= "<<diemTimKiem<<" la: ";
for(int i=1;i<=sl;i++){
if(sv[i].diemTK>= diemTimKiem){
sv[i].hienThiSinhVien();
count++;
if(count> 0){
else
void menu(){
cout<<endl<<"6. Thoat"<<endl;
main(){
system("cls");
SinhVien SV;
SV.khoiTaoFile();
do{
system("cls");
SV.docFile();
menu();
if(input=='6'){
break;
switch(input){
case ('1'):{
system("cls");
cin.ignore();
SV.nhapSV();
SV.ghiFile();
getch();
break;
case('2'):{
system("cls");
SV.sapXepTheoDTB();
getch();
break;
case('3'):{
system("cls");
SV.sapXepTheoHocBong();
getch();
break;
case('4'):{
system("cls");
SV.timTheoTen();
getch();
break;
case('5'):{
system("cls");
SV.timTheoDTK();
getch();
break;
default:{
getch();
}while(1);
getch();
Lp trnh C++ | Nhn xt(0) | Trch dn(0) | c(159) Vit nhn xt Hnh vui Tn gi
Mt khu
a ch web
[ng k]
Lch
CN T2 T6
1 24 8 9Thng 15 mng 8 22 15 29 22
T7
2 25 9 mng 2 16 mng 9 23 16 30 23
3 26 10 mng 3 17 mng 10 24 17 31 24
4 27 11 mng 4 18 11 25 18
5 28 12 mng 5 19 12 26 19
6 29 13 mng 6 20 13 27 20
7 30 14 mng 7 21 14 28 21
Thng k
Tm kim
Tm ki?m
Kt ni Nhm Kt ni mc nh
svptit dantri dqt'blog blackdiamond'sblog
H s 2010/10
2010/09 2010/08 2010/07 2010/06
Khc
ng nhp ng k Xin kt ni RSS Bi vit | Nhn xt MUTF-8 XHTML 1.0 Powered by Bo-Blog 2.1.1 Release |Skin by bluebee Run in 223 ms, 6 Queries