标题:
QT实现学生成绩管理系统可视化源码
[打印本页]
作者:
zhang643181810
时间:
2017-12-4 16:47
标题:
QT实现学生成绩管理系统可视化源码
给大家分享一个QT实现的学生成绩管理系统
0.png
(56.16 KB, 下载次数: 61)
下载附件
2017-12-4 18:03 上传
QT源程序如下:
#include "manage.h"
void manage::write() {
ofstream ofile;
ofile.open("c:\\student.txt");
for (int g = 0; g < m_count; g++)
{
ofile << stu[g].getid() << setw(10) << stu[g].getname() << setw(5) <<
stu[g].getmath() << setw(5) << stu[g].getphysics() << setw(5) << stu[g].getenglish() << endl;
}
ofile << "END";
ofile.close();
}
void manage::setcount(int a) {
m_count = a;
}
manage::manage() {
m_count = 0;
}
void manage::read() {
m_count = 0;
ifstream ifile;
ifile.open("c:\\student.txt");
string ID, Name;
int a, b, c;
while (1)
{
ifile >> ID >> Name >> a >> b >> c;
if (ID == "END")break;
student per(ID, Name, a, b, c);
stu[m_count] = per;
m_count++;
}
ifile.close();
}
int manage::search(string num) //精确查找
{
read();
int i = -1;
for (int mid = 0; mid<m_count; mid++)
{
if (stu[mid].getid() == num || stu[mid].getname() == num)
{
i = mid;
str = str + stu[i].getid() + " " + stu[i].getname() + " " + to_string(stu[i].getmath()) +
" " + to_string(stu[i].getphysics()) + " " + to_string(stu[i].getenglish()) +
" " + to_string(stu[i].gettotal()) + '\n';
return i;
}
}
if (i == -1)
return -1;
}
int manage::show() //显示所有学生成绩
{
str = str + " Id Name Math Physics English total\n";
for (int i = 0; i < m_count; i++) {
str = str + stu[i].getid() +'\t'+ stu[i].getname() + '\t' + to_string(stu[i].getmath()) +
'\t' + to_string(stu[i].getphysics()) +'\t' + to_string(stu[i].getenglish()) +
'\t' + to_string(stu[i].gettotal()) + '\n';
}
return 0;
}
int manage::deletein(int f) //删除
{
read();
for (int e = f; e <= m_count; e++)
{
stu[e] = stu[e + 1];
}
m_count--;
show();
write();
return m_count;
}
int manage::revise( int f,string str1,string str2,int a,int b,int c) //修改
{
read();
student per(str1, str2, a, b, c);
stu[f] = per;
show();
write();
return 0;
}
int manage::add(string rid,string rname,int ra,int rb,int rc) //添加(可以连续添加)
{
read();
student newper(rid, rname, ra, rb, rc);
stu[m_count] = newper;
m_count++;
show();
write();
return 0;
}
int manage::average(int num,int r) //统计分析(三个科目和总分的平均值,标准差,合格率)
{
read();
float a = 0, b = 0,c = 0;
float n;
int m, l, k;
float j;
if (num == 1)
{
for (m = 0; m<m_count; m++)
a += stu[m].getmath();
for (l = 0; l<m_count; l++)
b += ((stu[l].getmath() - a / m_count)*(stu[l].getmath() - a / m_count));
n = sqrt(b / m_count);
for (k = 0; k<m_count; k++)
{
if (stu[k].getmath() >= r)
c++;
}
j = c / m_count;
str = str + "The math's average is:"+to_string(a/m_count ) +'\n' + "The math's standard deviation is:"+to_string(n) +'\n' +
"The math's pass rate is:"+to_string(j ) +'\n' ;
}
if (num == 2)
{
for (m = 0; m<m_count; m++)
a += stu[m].getphysics();
for (l = 0; l<m_count; l++)
b += ((stu[l].getphysics() - a / m_count)*(stu[l].getphysics() - a / m_count));
n = sqrt(b / m_count);
for (k = 0; k<m_count; k++)
{
if (stu[k].getphysics() >= r)
c++;
}
j = c / m_count;
str = str + "The physics's average is:"+to_string(a/m_count ) +'\n' + "The physics's standard deviation is:"+to_string(n) +'\n' +
"The physics's pass rate is:"+to_string(j ) +'\n' ;
}
if (num == 3)
{
for (m = 0; m<m_count; m++)
a += stu[m].getenglish();
for (l = 0; l<m_count; l++)
b += ((stu[l].getenglish()- a / m_count)*(stu[l].getenglish() - a / m_count));
n = sqrt(b / m_count);
for (k = 0; k<m_count; k++)
{
if (stu[k].getenglish() >= r)
c++;
}
j = c / m_count;
str = str + "The english's average is:"+to_string(a/m_count ) +'\n' + "The english's standard deviation is:"+to_string(n) +'\n' +
"The english's pass rate is:"+to_string(j ) +'\n' ;
}
if (num == 4)
{
for (m = 0; m<m_count; m++)
a += (stu[m].gettotal());
for (l = 0; l<m_count; l++)
b += ((stu[l].gettotal()- a / m_count )*(stu[l].gettotal() - a / m_count));
n = sqrt(b / m_count);
for (k = 0; k<m_count; k++)
{
if (stu[k].gettotal() >= r)
c++;
}
j = c / m_count;
str = str + "The total_grade's average is:"+to_string(a/m_count ) +'\n' + "The total_grade's standard deviation is:"+to_string(n) +'\n' +
"The total_grade's pass rate is:"+to_string(j ) +'\n' ;
}
return 0;
}
void manage::setlist() //排序(先按总分,总分相同按数学,数学相同按物理,物理相同按英语)
{
read();
bool noswap;
int i, j;
student temp;
for (i = 0; i<m_count; i++)
{
noswap = true;
for (j = m_count; j>i; j--)
{
if (stu[j].gettotal()<stu[j - 1].gettotal())
{
temp = stu[j];
stu[j] = stu[j - 1];
stu[j - 1] = temp;
noswap = false;
}
if (stu[j].gettotal() == stu[j - 1].gettotal())
{
if (stu[j].getmath()<stu[j - 1].getmath())
{
temp = stu[j];
stu[j] = stu[j - 1];
stu[j - 1] = temp;
noswap = false;
}
if (stu[j].getmath() == stu[j - 1].getmath())
{
if (stu[j].getphysics()<stu[j - 1].getphysics())
{
temp = stu[j];
stu[j] = stu[j - 1];
stu[j - 1] = temp;
noswap = false;
}
if (stu[j].getphysics() == stu[j - 1].getphysics())
{
if (stu[j].getenglish()<stu[j - 1].getenglish())
{
temp = stu[j];
stu[j] = stu[j - 1];
stu[j - 1] = temp;
noswap = false;
}
}
}
}
}
if (noswap)break;
}
show();
}
void manage::ifind(string num) //模糊查询(输入姓名的一部分)
{
read();
int g;
for (int i = 0; i<m_count; i++)
{
g = stu[i].getname().find(num);
if (g != -1)
{
str = str + stu[i].getid() + " " + stu[i].getname() + " " + to_string(stu[i].getmath()) +
" " + to_string(stu[i].getphysics()) + " " + to_string(stu[i].getenglish()) +
" " + to_string(stu[i].gettotal()) + '\n';
}
}
}
void manage::score(int x,int min,int max) //输入分数段进行查询,查询单科成绩
{
read();
if (x == 1)
{
for (int i = 0; i<m_count; i++)
{
if (stu[i].getmath() >= min&&stu[i].getmath() <= max)
str = str + stu[i].getid() + " " + stu[i].getname() + " " + to_string(stu[i].getmath()) +
" " + to_string(stu[i].getphysics()) + " " + to_string(stu[i].getenglish()) +
" " + to_string(stu[i].gettotal()) + '\n';
}
}
if (x == 2)
……………………
…………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
studentQT.rar
(733.84 KB, 下载次数: 38)
2017-12-4 16:47 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1