急求 c++学生成绩管理系统源代码

1. 题目:学生成绩管理系统
要求:(1)依次录入学生信息:学号,班级,姓名,科目,成绩并生成一个.txt文件。
(2)可根据学号查询该学生的相关成绩。也可根据科目查询所有学生该课的成绩。
(3)可以查询某门课成绩在某一范围内的学生的相关信息,如:物理成绩在50~60之间。

(4)可添加或删除某个学生的相关信息。
不要上网档 我可以 增加悬赏 ……

第1个回答  推荐于2016-03-09
我可以帮你写~
不为分,希望你拿去好好看看,其实这个管理系统很简单.
还有些问题要问, 不要上网档啥意思?不需要把学生信息存入文件?每次运行都写自己在输入信息?
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;
class Student
{
public:
Student(){}
void write();
void red();
void show();
void sortScore();
int operator<(const Student&);
int a_bScore();
void deleteStudent();
private:
int id;
string name;
double score;
};
vector<Student> student;
void Student::write()
{
Student s;
char fileName[20];
cout<<"请输入文件名:"<<endl;
cin>>fileName;
cin.clear();
ofstream out(fileName,ios::app);
cout<<"请输入学生学号姓名成绩:"<<endl;
vector<Student>::iterator iter;
while (cin>>s.id>>s.name>>s.score)
{
iter=student.begin();
while (iter!=student.end())
{
if (s.id==iter->id)
{
cout<<s.id<<"已经存在。"<<endl;
cout<<iter->id<<"\t"<<iter->name<<" \t"<<iter->score<<endl;
break;
}
else
iter++;
}
if (iter==student.end())
{
out<<s.id<<" "<<s.name<<" "<<s.score<<" ";
student.push_back(s);
}
}
cin.clear();
}
void Student::show()
{
vector<Student>::const_iterator iter=student.begin();
cout<<"学号\t姓名\t 成绩\t"<<endl<<endl;
while (iter!=student.end())
{
cout<<iter->id<<"\t"<<iter->name<<" \t"<<iter->score<<endl;
iter++;
}
}
void Student::red()
{
Student s;
char fileName[20];
cout<<"请输入文件名:"<<endl;
cin>>fileName;
ifstream in(fileName);
vector<Student>::iterator iter;
while (in>>s.id>>s.name>>s.score)
{
iter=student.begin();
while (iter!=student.end())
{
if (s.id==iter->id)
{
break;
}
else
iter++;
}
if (iter==student.end())
{
student.push_back(s);
}
}
cin.clear();
}
int Student::operator<(const Student&s)
{
return score>s.score?1:0;
}
void Student::sortScore()
{
sort(student.begin(),student.end());
}
int Student::a_bScore()
{
int a,b,low,up,cnt=0;
cout<<"请输入要查找的分数段:"<<endl;
cin>>a>>b;
if (a>b)
{
up=a;
low=b;
}
else
{
low=a;
up=b;
}
vector<Student>::const_iterator iter=student.begin();
while (iter!=student.end())
{
if (iter->score>=low&&iter->score<=up)
{
cout<<iter->id<<"\t"<<iter->name<<" \t"<<iter->score<<endl;
cnt++;
}
iter++;
}
cout<<"分数段"<<low<<"~"<<up<<"总人数:"<<cnt<<endl;
return cnt;
}
void Student::deleteStudent()
{
Student s;
cout<<"请输入要删除的学生学号:"<<endl;
cin>>s.id;
vector<Student>::iterator iter=student.begin();
while (iter!=student.end())
{
if (iter->id==s.id)
{
break;
}
else
iter++;
if (iter!=student.end())
{
student.erase(iter);
cout<<"OK,"<<s.id<<"信息删除完毕。"<<endl;
}
else
{
cout<<"没找到学号为:"<<s.id<<"的学生信息,删除失败。"<<endl;
}
}
}
int main()
{
Student s;
int choice;
cout<<"=-=-=-=-=-=-=-=-=-=-=-=-=-=-欢迎使用学生信息管理系统-=-=-=-=-=-=-=-=-=-=-=-=-=-="<<endl;
begin:
cout<<"1->添加学生信息 2->显示学生信息 3->删除学生信息 "<<endl<<endl;
cout<<" 0-> 退出 "<<endl<<endl;
cout<<"4->从文件添加 5->按成绩排序 6->分数段信息查询"<<endl<<endl;

cin>>choice;
if (choice==1)
{
s.write();
system("cls");
goto begin;
}
else if (choice==2)
{
s.show();
system("pause");
system("cls");
goto begin;
}
else if (choice==3)
{
s.deleteStudent();
system("pause");
system("cls");
goto begin;
}
else if (choice==4)
{
s.red();
system("pause");
system("cls");
goto begin;
}
else if (choice==5)
{
s.sortScore();
system("pause");
system("cls");
goto begin;
}
else if (choice==6)
{
s.a_bScore();
system("pause");
system("cls");
goto begin;
}
else if (choice==0)
{
exit(0);
}
else
{
cout<<"输入非法!!!"<<endl;
system("pause");
goto begin;
}
return 0;
}

刚写完的~追问

就是不是在网上抄的 希望自己做的 我有问题可以回答的

追答

手写~
有啥尽管问,你不就是怕那去我的代码不会写文档么
问啥就Hi我

追问

哥们 你是按我的条件做的吗? 为什么会退出不了呢

追答

你提了问题我才去写得~ 完全一致

本回答被提问者采纳
相似回答