在好例子网,分享、交流、成长!
您当前所在位置:首页C/C++ 开发实例常规C/C++编程 → c++ 学生成绩管理系统 源码下载

c++ 学生成绩管理系统 源码下载

常规C/C++编程

下载此实例
  • 开发语言:C/C++
  • 实例大小:3.56M
  • 下载次数:119
  • 浏览次数:1016
  • 发布时间:2017-10-25
  • 实例类别:常规C/C++编程
  • 发 布 人:sk987176803
  • 文件格式:.zip
  • 所需积分:2

实例介绍

学生成绩管理系统
【实例截图】from clipboardfrom clipboardfrom clipboard

【核心代码】

#include<iostream>
#include<iomanip>
#include<fstream>
#include<stdlib.h>
#include<string>
#include<windows.h>
using namespace std;

class Student
{
public:
Student()
{
this->name="wu";
this->num=0;
this->yuwen=0;
this->shuxue=0;
this->yinyu=0;
this->average=0;
this->all=0;
}
Student(string name,double num,double yuwen,double shuxue,double yinyu)
{
this->name=name;
this->num=num;
this->yuwen=yuwen;
this->shuxue=shuxue;
this->yinyu=yinyu;
};
Student(Student &p)
{
name=p.name;
num=p.num;
yuwen=p.yuwen;
shuxue=p.shuxue;
yinyu=p.yinyu;
average=p.average;
all=p.all;
}
~Student(){};
void Setname(string name);
void Setnum(double num);
void Setyuwen(double yuwen);
void Setshuxue(double shuxue);
void Setyinyu(double yinyu);
void Setall(string name,double num,double yuwen,double shuxue,double yinyu);

protected:
double yuwen,shuxue,yinyu,average,all,num;
string name;
};
void Student::Setname(string name)
{
this->name=name;
}
void Student::Setnum(double num)
{
this->num=num;
}
void Student::Setyuwen(double yuwen)
{
this->yuwen=yuwen;
}
void Student::Setshuxue(double shuxue)
{
this->shuxue=shuxue;
}
void Student::Setyinyu(double yinyu)
{
this->yinyu=yinyu;
}
void Student::Setall(string name,double num,double yuwen,double shuxue,double yinyu)
{
this->name=name;
this->num=num;
this->yuwen=yuwen;
this->shuxue=shuxue;
this->yinyu=yinyu;
}
class fun:public Student
{
public:
void Display();
void Average();
void All();
void SC();
void XG();
void PM();
void CK();
void CZ();
void Luru();
void CP();
};
fun stu[100];
int DQ_num;
void fun::Display()
{
cout<<setiosflags(ios::left)<<setw(10)<<name;
cout<<setw(10)<<num<<setw(10)<<yuwen<<setw(10)<<shuxue<<setw(10)<<yinyu<<setw(10)<<average<<setw(10)<<all<<endl;
}
void fun::Average()
{
average=(yuwen shuxue yinyu)/3;
}
void fun::All()
{
all=yuwen shuxue yinyu;
}
void fun::CZ()
{
fun shift;
int i=0,n=DQ_num;
string strname;
int flag=0;
double strnum;
char ch;
system("cls");
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"******      ******"<<endl;
cout<<"****** 1.按学号查找      ******"<<endl;
cout<<"****** 2.按姓名查找      ******"<<endl;
cout<<"******              ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"请输入你的选择:";
cin>>ch;
if('1'==ch)
{
cout<<"请输入要查询学生的学号:";
cin>>strnum;
cout<<setw(10)<<"姓名"<<setw(10)<<"学号"<<setw(10)<<"语文"<<setw(10)<<"数学"<<setw(10)<<"外语"<<setw(10)<<"平均"<<setw(10)<<"总分"<<endl;
for(i=0;i<n;i )
{
if(strnum==stu[i].num)
{
stu[i].Display();
flag=1;
}
}
if(flag==0)
{
cout<<"没有该学生";
}
if(flag==1)
{
cout<<"查找成功!!";
}
cout<<"按任意键返回";
fflush(stdin);
getchar();
}
if('2'==ch)
{
cout<<"请输入要查询学生的姓名:";
cin>>strname;
cout<<setw(10)<<"姓名"<<setw(10)<<"学号"<<setw(10)<<"语文"<<setw(10)<<"数学"<<setw(10)<<"外语"<<setw(10)<<"平均"<<setw(10)<<"总分"<<endl;
for(i=0;i<n;i )
{
if(strname==stu[i].name)
{
stu[i].Display();
flag=1;
}
}
if(flag==0)
{
cout<<"没有该学生";
}
if(flag==1)
{
cout<<"查找成功!!";
}
cout<<"按任意键返回";
fflush(stdin);
getchar();
}
}
void fun::PM()
{
system("cls");
fun shift;
int i=DQ_num,j,k;
char ch;
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"******      ******"<<endl;
cout<<"****** 1.按学号排名      ******"<<endl;
cout<<"****** 2.按总分排名      ******"<<endl;
cout<<"****** 3.按语文排名      ******"<<endl;
cout<<"****** 4.按数学排名      ******"<<endl;
cout<<"****** 5.按外语排名      ******"<<endl;
cout<<"****** 6.各个分数段信息      ******"<<endl;
cout<<"******              ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"请输入你的选择:";
cin>>ch;
if(ch=='1')
{
for(j=0;j<i;j )
{
for(k=j 1;k<i;k )
{
if(stu[j].num>stu[k].num)
{
shift=stu[j];
stu[j]=stu[k];
stu[k]=shift;
}
}
}
cout<<"排名成功。。。。按任意键返回";
}
else if(ch=='2')
{
for(j=0;j<i;j )
{
for(k=j 1;k<i;k )
{
if(stu[j].all<stu[k].all)
{
shift=stu[j];
stu[j]=stu[k];
stu[k]=shift;
}
}
}
cout<<"排名成功。。。。按任意键返回";
}
else if(ch=='3')
{
for(j=0;j<i;j )
{
for(k=j 1;k<i;k )
{
if(stu[j].yuwen<stu[k].yuwen)
{
shift=stu[j];
stu[j]=stu[k];
stu[k]=shift;
}
}
}
cout<<"排名成功。。。。按任意键返回";
}
else if(ch=='4')
{
for(j=0;j<i;j )
{
for(k=j 1;k<i;k )
{
if(stu[j].shuxue<stu[k].shuxue)
{
shift=stu[j];
stu[j]=stu[k];
stu[k]=shift;
}
}
}
cout<<"排名成功。。。。按任意键返回";
}
else if(ch=='5')
{
for(j=0;j<i;j )
{
for(k=j 1;k<i;k )
{
if(stu[j].yinyu<stu[k].yinyu)
{
shift=stu[j];
stu[j]=stu[k];
stu[k]=shift;
}
}
}
cout<<"排名成功。。。。按任意键返回";
}
else if(ch=='6')
{
int n=0;
string str;
float n1;
float q,h,t;
cout<<"请输入学科(中文):";
cin>>str;
while(str!="语文"&&str!="数学"&&str!="英语")
{
cout<<"没有该学科,从新输入"<<endl;
cout<<"请输入学科(拼音):";
cin>>str;
}
cout<<"请输入分数段(0—100)";
cin>>q>>h;
while(q<0||q>100||h<0||h>100)
{
cout<<"输入有误,从新输入"<<endl;
cout<<"请输入分数段(0—100)";
cin>>q>>h;
}
if(q>h)
{
t=q;
q=h;
h=t;
}
if(str=="语文")
{
for(j=0;j<i;j )
{
if(stu[j].yuwen>=q&&stu[j].yuwen<=h)
{
n ;
}
}
n1=((float)n/i)*100;
cout<<"该分数段的学生人数为"<<n<<"占总人数的百分比为"<<n1<<"%"<<endl;
}
if(str=="数学")
{
for(j=0;j<i;j )
{
if(stu[j].shuxue>=q&&stu[j].shuxue<=h)
{
n ;
}
}
n1=((float)n/i)*100;
cout<<"该分数段的学生人数为"<<n<<"占总人数的百分比为"<<n1<<"%"<<endl;
}
if(str=="英语")
{
for(j=0;j<i;j )
{
if(stu[j].yinyu>=q&&stu[j].yinyu<=h)
{
n ;
}
}
n1=((float)n/i)*100;
cout<<"该分数段的学生人数为"<<n<<"占总人数的百分比为"<<n1<<"%"<<endl;
}

}
cout<<"按任意键返回";
fflush(stdin);
getchar();
}
void fun::XG()
{
double str;
int i=DQ_num,j;
system("cls");
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"请输入想修改的学号:";
cin>>str;
for(j=0;j<i;j )
{
if(stu[j].num==str)
{
double yw,sx,yy,nu;
string n;
int m=0;
cout<<setw(5)<<"姓名"<<setw(10)<<"学号"<<setw(10)<<"语文"<<setw(10)<<"数学"<<setw(10)<<"外语"<<setw(10)<<"平均"<<setw(10)<<"总分"<<endl;
stu[j].Display();
cout<<"请输入:"<<endl;
cout<<"姓名";
cin>>n;
cout<<"学号";
cin>>nu;
while(m<DQ_num)
{
if(stu[m].num==nu&&m!=j)
{
cout<<"该学号已存在,请从新输入"<<endl;
cout<<"学号";
cin>>nu;
i=0;
}
m ;
}
cout<<"语文";
cin>>yw;
while(yw>100||yw<0)
{
cout<<"不符合逻辑请从新输入"<<endl;
cout<<"语文";
cin>>yw;
}
cout<<"数学";
cin>>sx;
while(sx>100||sx<0)
{
cout<<"不符合逻辑请从新输入"<<endl;
cout<<"数学";
cin>>sx;
}
cout<<"英语";
cin>>yy;
while(yy>100||yy<0)
{
cout<<"不符合逻辑请从新输入"<<endl;
cout<<"英语";
cin>>yy;
}
stu[j].Setall(n,nu,yw,sx,yy);
stu[j].Average();
stu[j].All();
cout<<setw(5)<<"姓名"<<setw(10)<<"学号"<<setw(10)<<"语文"<<setw(10)<<"数学"<<setw(10)<<"外语"<<setw(10)<<"平均"<<setw(10)<<"总分"<<endl;
stu[j].Display();
cout<<"修改成功";
fflush(stdin);
cout<<"按任意键返回";
getchar();
break;
}
}
if(i==j)
{
cout<<"没有该学生。。。。按任意键返回";
fflush(stdin);
getchar();
}
}
void fun::SC()
{
system("cls");
double str;
char ch;
int i=DQ_num,j,flag=0;
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"请输入想删除的学号:";
cin>>str;
for(j=0;j<i;j )
{
if(stu[j].num==str)
{
cout<<"是否要删除?Y/N";
cin>>ch;
if(ch=='Y'||ch=='y')
{
stu[j].Setnum(0);
flag=1;
}
else if(ch=='N'||ch=='n')
{
flag=2;
cout<<"按任意键返回";
getchar();
}
}
}
if(0==flag)
{
cout<<"没有该学生。。。。按任意键返回";
fflush(stdin);
getchar();
}
else if(1==flag)
{
cout<<"删除成功。。。。按任意键返回";
fflush(stdin);
getchar();
}
if(2==flag)
{};

void fun::Luru()
{
system("cls");
fun clas;
int i=0,j,m;
double yw,sx,yy,nu;
string n;
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"请输入要输入的学生人数:"<<endl;
cin>>m;
for(j=0;j<m;j )
{
cout<<"输入第"<<j 1<<"个学生的信息"<<endl;
cout<<"姓名";
cin>>n;
cout<<"学号";
cin>>nu;
while(i<DQ_num)
{
if(stu[i].num==nu)
{
cout<<"该学号已存在,请从新输入"<<endl;
cout<<"学号";
cin>>nu;
i=0;
}
i ;
}
cout<<"语文";
cin>>yw;
while(yw>100||yw<0)
{
cout<<"不符合逻辑请从新输入"<<endl;
cout<<"语文";
cin>>yw;
}
cout<<"数学";
cin>>sx;
while(sx>100||sx<0)
{
cout<<"不符合逻辑请从新输入"<<endl;
cout<<"数学";
cin>>sx;
}
cout<<"英语";
cin>>yy;
while(yy>100||yy<0)
{
cout<<"不符合逻辑请从新输入"<<endl;
cout<<"英语";
cin>>yy;
}
stu[DQ_num].Setall(n,nu,yw,sx,yy);
stu[DQ_num].Average();
stu[DQ_num].All();
cout<<setw(10)<<"姓名"<<setw(10)<<"学号"<<setw(10)<<"语文"<<setw(10)
<<"数学"<<setw(10)<<"外语"<<setw(10)<<"平均"<<setw(10)<<"总分"<<endl;
stu[DQ_num].Display();
DQ_num ;
}
cout<<"按任意键返回";
fflush(stdin);
getchar();
}
void fun::CK()
{
fun clas;
int i=0;
system("cls");
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<setw(10)<<"姓名"<<setw(10)<<"学号"<<setw(10)<<"语文"<<setw(10)<<"数学"<<setw(10)<<"外语"<<setw(10)<<"平均"<<setw(10)<<"总分"<<endl;
for(i=0;i<DQ_num;i )
{
if(stu[i].num!=0)
stu[i].Display();
}
cout<<"按任意键返回";
fflush(stdin);
getchar();
}
void fun::CP()
{
char ch;
system("cls");
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"是否确定存盘,存盘将会覆盖以前的数据?(Y/N)";
cin>>ch;
if(ch=='Y'||ch=='y')
{
int j;
ofstream outfile;
outfile.open("f1.txt",ios::out);
if(!outfile)
{
outfile.close();
cout<<"文件打开错误!......按任意键返回";
getchar();
}
else
{
for(j=0;j<DQ_num&&stu[j].num!=0;j )
outfile<<stu[j].name<<" "
<<stu[j].num<<" "
<<stu[j].yuwen<<" "
<<stu[j].shuxue<<" "
<<stu[j].yinyu<<" "
<<stu[j].average<<" "
<<stu[j].all<<" ";
cout<<"存入成功";
}
}
if(ch=='N'||ch=='n')
{}
fflush(stdin);
cout<<"按任意键返回";
getchar();
}
void main()
{
char ch;
fun clas;
int i=0;
ifstream inFile;
inFile.open("f1.txt",ios::in);
if(!inFile)
{
cout<<"文件打开错误!";
fflush(stdin);
getchar();
inFile.close();
}
while(!inFile.eof())
{
double yw,sx,yy,av,al,nu;
string n;
inFile>>n;
inFile>>nu;
inFile>>yw;
inFile>>sx;
inFile>>yy;
inFile>>av;
inFile>>al;
if(i==0)
{
stu[i].Setall(n,nu,yw,sx,yy);
stu[i].Average();
stu[i].All();
i ;
if(inFile.eof())
break;
}
else
{
if(inFile.eof())
break;
stu[i].Setall(n,nu,yw,sx,yy);
stu[i].Average();
stu[i].All();
i ;
}
}
inFile.close();
DQ_num=i;
while(1)
{
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
cout<<"********************************************************************"<<endl;
cout<<"****** 学生成绩管理系统      ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"******      ******"<<endl;
cout<<"****** 1.学生数据录入      ******"<<endl;
cout<<"****** 2.成绩统计排名      ******"<<endl;
cout<<"****** 3.修改      ******"<<endl;
cout<<"****** 4.删除      ******"<<endl;
cout<<"****** 5.查看      ******"<<endl;
cout<<"****** 6.查找              ******"<<endl;
cout<<"****** 7.存盘              ******"<<endl;
cout<<"****** 8.退出              ******"<<endl;
cout<<"******              ******"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"********************************************************************"<<endl;
cout<<"请输入你的选择:";
cin>>ch;
switch(ch)
{
case '1':
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_BLUE);
clas.Luru();break;
}
case '2':
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
clas.PM();break;
}
case '3':
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
clas.XG();break;
}
case '4':
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN);
clas.SC();break;
}
case '5':
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN);
clas.CK();break;
}
case '6':
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN);
clas.CZ();break;
}
case '7':
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
clas.CP();break;
}
case '8':exit(0);
}
}
}



实例下载地址

c++ 学生成绩管理系统 源码下载

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警