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

📄 stu_main.cpp

📁 课程设计 大二的课程设计源码 有需要的都来下啊 能出结果挺好用的
💻 CPP
字号:
#include<iostream.h>
#include<process.h>
#include<fstream.h>
#include"Student.h"
const char*student_file="student.txt";
int sum=0;
int writemessage()
{
	fstream output_file;//写
	Student obj;
	cout<<"请输入学生信息:\n编号,姓名,性别,年龄,数学成绩,计算机成绩,英语成绩:";
	cin>>obj.Cstudent::num>>obj.Cstudent::name>>obj.sex>>obj.age>>obj.math>>obj.computer>>obj.english;
	strcpy(obj.Cscores::name,obj.Cstudent::name);
	obj.Cscores::num=obj.Cstudent::num;
	strcpy(obj.Cscores::name,obj.Cstudent::name);
	output_file.open(student_file,ios::out|ios::binary|ios::ate);
	if(!output_file){
		cout<<"can not open student_file"<<endl;
		return 1;		
	}
	output_file.seekp(sizeof(class Student)*(obj.Cstudent::num-1),ios::beg);
	output_file<<obj.Cstudent::num<<"\t"<<obj.Cstudent::name<<"\t"<<obj.sex<<"\t"<<obj.age<<"\t"<<obj.math<<"\t"<<obj.computer<<"\t"<<obj.english;
	output_file.close();
	if(obj.Cstudent::num>sum)
		sum=obj.Cstudent::num;
	return 0;
}
int readmessage(int number,Student&obj)
{
	fstream input_file;//读	
	
	input_file.open(student_file,ios::in|ios::binary);
	if(!input_file){
		cout<<"can not open student_file"<<endl;
		return 1;
	}
	if(number>sum||number<1)
		return 1;
	input_file.seekg(sizeof(class Student)*(number-1),ios::beg);
	input_file>>obj.Cstudent::num>>obj.Cstudent::name>>obj.sex>>obj.age>>obj.math>>obj.computer>>obj.english;
	input_file.close();
	return 0;
}
void main()
{
	cout<<"*********************考研学生情况处理系统*************************"<<endl;
	int choice=0;
	Student Stu;
	cout<<"请选择要进行的操作:"<<endl;
	cout<<"1.按编号输入学生信息"<<endl;
	cout<<"2.按编号查询学生信息"<<endl;
	cout<<"3.按姓名查询学生信息"<<endl;
	cout<<"4.按编号计算总成绩与平均成绩"<<endl;
	cout<<"5.列出分数超过270分的学生成绩"<<endl;
	cout<<"6.退出"<<endl;
	cout<<"7.清空已有数据"<<endl;
	cin>>choice;
	while(choice>0&&choice<8)
	{
		switch(choice)
		{
		case 1:
			writemessage();
			break;
		case 2:
			Stu.shownum();
			break;
		case 3:
			if(!Stu.showname())
				cout<<"无此学生!";
			break;
		case 4:
		    Stu.showscore();
			break;
		case 5:
			Stu.liechu();
			break;
		case 6:
			exit(0);
		case 7:
			Stu.destroydata();
			break;
		default:
			cout<<"error!";
			break;
		}
		cout<<"请选择要进行的操作:"<<endl;
		cin>>choice;
	}

}

⌨️ 快捷键说明

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