找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5014|回复: 0
打印 上一主题 下一主题
收起左侧

QT实现学生成绩管理系统可视化源码

[复制链接]
跳转到指定楼层
楼主
给大家分享一个QT实现的学生成绩管理系统


QT源程序如下:
  1. #include "manage.h"

  2. void manage::write() {
  3.     ofstream ofile;
  4.     ofile.open("c:\\student.txt");
  5.     for (int g = 0; g < m_count; g++)
  6.     {
  7.         ofile << stu[g].getid() << setw(10) << stu[g].getname() << setw(5) <<
  8.             stu[g].getmath() << setw(5) << stu[g].getphysics() << setw(5) << stu[g].getenglish() << endl;
  9.     }
  10.     ofile << "END";
  11.     ofile.close();
  12. }
  13. void manage::setcount(int a) {
  14.     m_count = a;
  15. }
  16. manage::manage() {
  17.     m_count = 0;
  18. }
  19. void manage::read() {
  20.     m_count = 0;
  21.     ifstream ifile;
  22.     ifile.open("c:\\student.txt");
  23.     string ID, Name;
  24.     int a, b, c;
  25.     while (1)
  26.     {
  27.         ifile >> ID >> Name >> a >> b >> c;
  28.         if (ID == "END")break;
  29.         student per(ID, Name, a, b, c);
  30.         stu[m_count] = per;
  31.         m_count++;
  32.     }
  33.     ifile.close();
  34. }
  35. int manage::search(string num)                                     //精确查找
  36. {
  37.     read();
  38.     int i = -1;
  39.     for (int mid = 0; mid<m_count; mid++)
  40.     {
  41.         if (stu[mid].getid() == num || stu[mid].getname() == num)
  42.         {
  43.             i = mid;
  44.             str = str + stu[i].getid() + "         " + stu[i].getname() + "     " + to_string(stu[i].getmath()) +
  45.             "     " + to_string(stu[i].getphysics()) + "     " + to_string(stu[i].getenglish()) +
  46.             "     " + to_string(stu[i].gettotal()) + '\n';
  47.             return i;
  48.         }
  49.     }
  50.     if (i == -1)
  51.         return -1;
  52. }
  53. int manage::show()                                         //显示所有学生成绩
  54. {
  55.     str = str + "      Id      Name         Math        Physics       English      total\n";
  56.     for (int i = 0; i < m_count; i++) {
  57.         str = str + stu[i].getid() +'\t'+ stu[i].getname() + '\t' + to_string(stu[i].getmath()) +
  58.             '\t' + to_string(stu[i].getphysics()) +'\t' + to_string(stu[i].getenglish()) +
  59.             '\t' + to_string(stu[i].gettotal()) + '\n';
  60.     }
  61.     return 0;
  62. }
  63. int manage::deletein(int f)                         //删除
  64. {
  65.     read();

  66.     for (int e = f; e <= m_count; e++)
  67.     {
  68.         stu[e] = stu[e + 1];
  69.     }
  70.     m_count--;
  71.     show();
  72.     write();
  73.     return m_count;
  74. }
  75. int manage::revise( int f,string str1,string str2,int a,int b,int c)                                           //修改
  76. {
  77.     read();
  78.     student per(str1, str2, a, b, c);
  79.     stu[f] = per;
  80.     show();
  81.     write();
  82.     return 0;
  83. }
  84. int manage::add(string rid,string rname,int ra,int rb,int rc)                                            //添加(可以连续添加)
  85. {
  86.     read();
  87.     student newper(rid, rname, ra, rb, rc);
  88.     stu[m_count] = newper;
  89.     m_count++;
  90.     show();
  91.     write();
  92.     return 0;
  93. }
  94. int manage::average(int num,int r)                   //统计分析(三个科目和总分的平均值,标准差,合格率)
  95. {
  96.     read();
  97.     float a = 0, b = 0,c = 0;
  98.     float n;
  99.     int m, l, k;
  100.     float j;
  101.     if (num == 1)
  102.     {
  103.         for (m = 0; m<m_count; m++)
  104.             a += stu[m].getmath();
  105.         for (l = 0; l<m_count; l++)
  106.             b += ((stu[l].getmath() - a / m_count)*(stu[l].getmath() - a / m_count));
  107.         n = sqrt(b / m_count);
  108.         for (k = 0; k<m_count; k++)
  109.         {
  110.             if (stu[k].getmath() >= r)
  111.                 c++;
  112.         }
  113.         j = c / m_count;
  114.         str = str  + "The math's average is:"+to_string(a/m_count ) +'\n' + "The math's standard deviation is:"+to_string(n) +'\n' +
  115.                 "The math's pass rate is:"+to_string(j ) +'\n' ;

  116.     }
  117.     if (num == 2)
  118.     {
  119.         for (m = 0; m<m_count; m++)
  120.             a += stu[m].getphysics();
  121.         for (l = 0; l<m_count; l++)
  122.             b += ((stu[l].getphysics() - a / m_count)*(stu[l].getphysics() - a / m_count));
  123.         n = sqrt(b / m_count);
  124.         for (k = 0; k<m_count; k++)
  125.         {
  126.             if (stu[k].getphysics() >= r)
  127.                 c++;
  128.         }
  129.         j = c / m_count;
  130.         str = str  + "The physics's average is:"+to_string(a/m_count ) +'\n' + "The physics's standard deviation is:"+to_string(n) +'\n' +
  131.                 "The physics's pass rate is:"+to_string(j ) +'\n' ;
  132.     }
  133.     if (num == 3)
  134.     {
  135.         for (m = 0; m<m_count; m++)
  136.             a += stu[m].getenglish();
  137.         for (l = 0; l<m_count; l++)
  138.             b += ((stu[l].getenglish()- a / m_count)*(stu[l].getenglish() - a / m_count));
  139.         n = sqrt(b / m_count);
  140.         for (k = 0; k<m_count; k++)
  141.         {
  142.             if (stu[k].getenglish() >= r)
  143.                 c++;
  144.         }
  145.         j = c / m_count;
  146.         str = str  + "The english's average is:"+to_string(a/m_count ) +'\n' + "The english's standard deviation is:"+to_string(n) +'\n' +
  147.                 "The english's pass rate is:"+to_string(j ) +'\n' ;
  148.     }
  149.     if (num == 4)
  150.     {
  151.         for (m = 0; m<m_count; m++)
  152.             a += (stu[m].gettotal());
  153.         for (l = 0; l<m_count; l++)
  154.             b += ((stu[l].gettotal()- a / m_count )*(stu[l].gettotal() - a / m_count));
  155.         n = sqrt(b / m_count);
  156.         for (k = 0; k<m_count; k++)
  157.         {
  158.             if (stu[k].gettotal() >= r)
  159.                 c++;
  160.         }
  161.         j = c / m_count;
  162.         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' +
  163.                 "The total_grade's pass rate is:"+to_string(j ) +'\n' ;
  164.     }
  165.     return 0;
  166. }
  167. void manage::setlist()                                             //排序(先按总分,总分相同按数学,数学相同按物理,物理相同按英语)
  168. {
  169.     read();
  170.     bool noswap;
  171.     int i, j;
  172.     student temp;
  173.     for (i = 0; i<m_count; i++)
  174.     {
  175.         noswap = true;
  176.         for (j = m_count; j>i; j--)
  177.         {
  178.             if (stu[j].gettotal()<stu[j - 1].gettotal())
  179.             {
  180.                 temp = stu[j];
  181.                 stu[j] = stu[j - 1];
  182.                 stu[j - 1] = temp;
  183.                 noswap = false;
  184.             }
  185.             if (stu[j].gettotal() == stu[j - 1].gettotal())
  186.             {
  187.                 if (stu[j].getmath()<stu[j - 1].getmath())
  188.                 {
  189.                     temp = stu[j];
  190.                     stu[j] = stu[j - 1];
  191.                     stu[j - 1] = temp;
  192.                     noswap = false;
  193.                 }
  194.                 if (stu[j].getmath() == stu[j - 1].getmath())
  195.                 {
  196.                     if (stu[j].getphysics()<stu[j - 1].getphysics())
  197.                     {
  198.                         temp = stu[j];
  199.                         stu[j] = stu[j - 1];
  200.                         stu[j - 1] = temp;
  201.                         noswap = false;
  202.                     }
  203.                     if (stu[j].getphysics() == stu[j - 1].getphysics())
  204.                     {
  205.                         if (stu[j].getenglish()<stu[j - 1].getenglish())
  206.                         {
  207.                             temp = stu[j];
  208.                             stu[j] = stu[j - 1];
  209.                             stu[j - 1] = temp;
  210.                             noswap = false;
  211.                         }
  212.                     }
  213.                 }
  214.             }
  215.         }
  216.         if (noswap)break;
  217.     }
  218.     show();
  219. }
  220. void manage::ifind(string num)                                                  //模糊查询(输入姓名的一部分)
  221. {
  222.     read();
  223.     int g;
  224.     for (int i = 0; i<m_count; i++)
  225.     {
  226.         g = stu[i].getname().find(num);
  227.         if (g != -1)
  228.         {
  229.             str = str + stu[i].getid() + "         " + stu[i].getname() + "     " + to_string(stu[i].getmath()) +
  230.                 "     " + to_string(stu[i].getphysics()) + "     " + to_string(stu[i].getenglish()) +
  231.                 "     " + to_string(stu[i].gettotal()) + '\n';
  232.         }
  233.     }
  234. }
  235. void manage::score(int x,int min,int max)                                     //输入分数段进行查询,查询单科成绩
  236. {
  237.     read();
  238.     if (x == 1)
  239.     {
  240.         for (int i = 0; i<m_count; i++)
  241.         {
  242.             if (stu[i].getmath() >= min&&stu[i].getmath() <= max)
  243.                 str = str + stu[i].getid() + "         " + stu[i].getname() + "     " + to_string(stu[i].getmath()) +
  244.                 "     " + to_string(stu[i].getphysics()) + "     " + to_string(stu[i].getenglish()) +
  245.                 "     " + to_string(stu[i].gettotal()) + '\n';
  246.         }
  247.     }
  248.     if (x == 2)
  249. ……………………

  250. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
studentQT.rar (733.84 KB, 下载次数: 37)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表