⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 student.cpp

📁 这是一个学生成绩管理系统.这个程序的主要功能是输入学生的学号、姓名对其进行存储
💻 CPP
字号:
#include <string.h>
#include <iostream.h>
#include "stu_interface.h"
int cnt=0;
const char *student_file="stu.dat";

STUDENT::STUDENT(){read();}

STUDENT::~STUDENT(){}

void STUDENT::input()
{
	int n;
	cout<<"输入学生的个数:";
	cin>>n;
	cout<<"姓名\t"<<"学号\t"<<"Java\t"<<"电子商务\t"<<"面向对象\t"<<"VB\t"<<"客户关系\t"<<endl;
	for(int i=1;i<=n;i++)
	{
			cin>>student[cnt].stu_na>>student[cnt].stu_id>>student[cnt].java>>student[cnt].EC>>student[cnt].OOP >>student[cnt].VB>>student[cnt].CRM;
	}
	for (int j=0;j<cnt ;j++ )
	{
		if (strcmp(student[cnt].stu_na,student[j].stu_na)!=0) continue;
		else
		{
			cout<<student[cnt].stu_na<<"该学生已经存在!"<<endl;
			return;
		}
	}
	cnt++;

}

void STUDENT::show_file()
{
	int i;
	if(cnt==0) {cout<<"暂时还没有记录!";return;}
	cout<<"姓名\t"<<"学号\t"<<"Java\t"<<"电子商务\t"<<"面向对象\t"<<"VB\t"<<"客户关系\t"<<endl;
	for (i=0;i<cnt ;i++ )
	{
		cout<<student[i].stu_na<<"\t"<<student[i].stu_id<<"\t"<<student[i].java<<"\t"<<student[i].EC<<"\t"<<student[i].OOP<<"\t"<<student[i].VB<<"\t"<<student[i].CRM<<"\t"<<endl;
	}
}

void STUDENT::show(int i)
{
	if(cnt==0) {cout<<"暂时还没有记录!";return;}
	cout<<"姓名\t"<<"学号\t"<<"Java\t"<<"电子商务\t"<<"面向对象\t"<<"VB\t"<<"客户关系\t"<<endl;
	cout<<student[i].stu_na<<"\t"<<student[i].stu_id<<"\t"<<student[i].java<<"\t"<<student[i].EC<<"\t"<<student[i].OOP<<"\t"<<student[i].VB<<"\t"<<student[i].CRM<<"\t"<<endl;
}

void STUDENT::search_na()
{
	if(cnt==0) {cout<<"文件里面没有记录";return;}
	char stu_na[10];
	cout<<"输入你要查找的姓名:";
	cin>>stu_na;
	for(int i=0;i<=cnt;i++)
		if(strcmp(stu_na,student[i].stu_na)==0)
	{
        show(i);return;
	}
	else continue;
	cout<<stu_na<<"没有查到记录"<<endl;
}

void STUDENT::search_id()
{
	if(cnt==0) {cout<<"文件里面没有记录";return;}
	long stu_id;
	cout<<"输入你要查找的学号:";
	cin>>stu_id;
	for(int i=0;i<=cnt;i++)
		if(stu_id==student[i].stu_id)
	{
        show(i);return;
	}
	else continue;
	cout<<stu_id<<"没有查到记录"<<endl;
}

void STUDENT::read()
{
    ifstream input_file;
	input_file.open(student_file);
	if(!input_file)
	{
	 cout<<"不能打开文件!"<<endl;
	 return;
	}
	while(!input_file.eof())
	{
	 input_file>>student[cnt].stu_na>>student[cnt].stu_id>>student[cnt].java>>student[cnt].EC>>student[cnt].OOP >>student[cnt].VB>>student[cnt].CRM;
     cnt++;
	}
	cnt--;
	input_file.close();
}


void STUDENT::save()
{
	ofstream output_file;
	output_file.open(student_file);
	if(!output_file)
	{
		cout<<"系统错误!不能打开文件!"<<endl;
		return;
	}
	for (int i=0;i<cnt ;i++ )
	{
		output_file<<student[i].stu_na<<"\t"<<student[i].stu_id<<"\t"<<student[i].java<<"\t"<<student[i].EC<<"\t"<<student[i].OOP<<"\t"<<student[i].VB<<"\t"<<student[i].CRM<<"\t"<<endl;
	}
	output_file.close();
}

void STUDENT::show_help()
{   cout<<"\n\n\n\n\n";
	cout<<"\t\t\t----------------系统帮助-----------------"<<endl;
	cout<<"\t\t\t---F1:输入学生信息"<<endl;
    cout<<"\t\t\t---F2:根据学生学号查询"<<endl;
	cout<<"\t\t\t---F3:根据学生姓名查询"<<endl;
	cout<<"\t\t\t---F4:输出文件里面的信息"<<endl;
	cout<<"\t\t\t---F5:统计合格和优秀的人数"<<endl;
	cout<<"\t\t\t---ESC:退出系统"<<endl;
}

void STUDENT::statistics()
{
int pass=0;
int good=0;
for(int i=0;i<=cnt;i++)
{
if(student[i].java>=60 && student[i].EC>=60 && student[i].VB>=60 && student[i].OOP>=60 && student[i].CRM>=60) pass++;
if(student[i].java>=80 && student[i].EC>=80 && student[i].VB>=80 && student[i].OOP>=80 && student[i].CRM>=80) good++;
}
cout<<"\n\n"<<endl;
cout<<"\t\t---及格人数:"<<pass<<endl;
cout<<"\t\t---优秀人数:"<<good<<endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -