




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、中國(guó)地質(zhì)大學(xué)計(jì)算機(jī)高級(jí)語(yǔ)言課程設(shè)計(jì)報(bào)告(QT設(shè)計(jì)) 學(xué)生成績(jī)管理系統(tǒng)班級(jí):191142班學(xué)號(hào):姓名:日期:2015年7月2日一 課程設(shè)計(jì)題目與要求 (包括題目與系統(tǒng)功能要求)【實(shí)習(xí)內(nèi)容】C+語(yǔ)言,面向?qū)ο蟮姆治雠c設(shè)計(jì)。然后改成QT語(yǔ)言。【基本要求】學(xué)生成績(jī)管理是高等學(xué)校教務(wù)管理的重要組成部分,主要包括學(xué)生成績(jī)的錄入、刪除、查找及修改、成績(jī)的統(tǒng)計(jì)分析等等。請(qǐng)?jiān)O(shè)計(jì)一個(gè)系統(tǒng)實(shí)現(xiàn)對(duì)學(xué)生成績(jī)的管理。系統(tǒng)要求實(shí)現(xiàn)以下功能:(1)增加記錄:要求可以連續(xù)增加多條記錄。(2)刪除一個(gè)學(xué)生的記錄:要求可以先查找,再刪除。刪除前,要求用戶(hù)確認(rèn)。(3)成績(jī)修改:若輸入錯(cuò)誤可進(jìn)行修改;要求可以先查找,再修改。(4)查找
2、:可以根據(jù)姓名(或?qū)W號(hào))查找某個(gè)學(xué)生的課程成績(jī),查找某門(mén)課程成績(jī)處于指定分?jǐn)?shù)段內(nèi)的學(xué)生名單等等。(5)統(tǒng)計(jì)分析:對(duì)某個(gè)班級(jí)學(xué)生的單科成績(jī)進(jìn)行統(tǒng)計(jì),求出平均成績(jī);求平均成績(jī)要求實(shí)現(xiàn)函數(shù)的重載,既能求單科的平均成績(jī),又能求三科總分的平均成績(jī)。求出一門(mén)課程標(biāo)準(zhǔn)差和合格率;(6)排序功能:要求按總分進(jìn)行排序(從高到低),若總分相同,則按數(shù)學(xué)排序;若總分和數(shù)學(xué)相同,則按物理排序;若總分和各科成績(jī)都相同,則按學(xué)號(hào)排序;(7)文件操作:可以打開(kāi)文件,顯示班級(jí)的所有學(xué)生信息;可以將增加或修改后的成績(jī)重新寫(xiě)入文件;可以將排序好的信息寫(xiě)入新的文件?!据^高要求】查找可以實(shí)現(xiàn)模糊查詢(xún),即輸入名字的一部分,可以列出滿足
3、條件的所有記錄。再?gòu)倪@個(gè)記錄中進(jìn)行二次選擇。二 需求分析【問(wèn)題描述】在編寫(xiě)過(guò)程中,主要的困難有:1. 模糊搜索(不能使用string中的find函數(shù))需要自定義一個(gè)函數(shù)。2. 排序,需要自己學(xué)習(xí)算法?!鞠到y(tǒng)環(huán)境】三 概要設(shè)計(jì)【類(lèi)的設(shè)計(jì)】:類(lèi)Student:#ifndef STUDENT_H#define STUDENT_H#include<iostream>#include<vector>#include<fstream>#include<string>#include<iomanip>#include<cmath>usi
4、ng namespace std;class studentprivate: string m_id, m_name; int m_math, m_eng, m_phy;public: student(); student(string, string, int, int, int); /構(gòu)造函數(shù) student(const student &); /復(fù)制構(gòu)造函數(shù) student(); / 析構(gòu)函數(shù) string getId(); /自定義接口 string getName(); intgetMath(); int getEng(); int getPhy(); int total()
5、; student operator=(const student &); / =號(hào)重載;#endif / STUDENT_H#define MANAGEMENT#include "student.h"#include"QString"#include<QFileDialog>#include<QFile>#include<qtextstream.h>class managementprivate: vector<student>stu;public: vector<student> d
6、eletetxt(const string& m); /刪除記錄 vector<student> findtxt(const string& m); /模糊搜索 vector<student> findtxt1(int,int,const string&); /分?jǐn)?shù)段搜索 vector<student> itxt(); /文件寫(xiě)入 vector<student> getstu()return stu; vector<double> ttxt(vector<double>); /統(tǒng)計(jì)分析 vector
7、<student> ptxt(); /排序 void addtxt(); /增加記錄 void changetxt(); /成績(jī)修改 void otxt(); /文件輸出 void show(); /輸出;#endif / MANAGEMENT類(lèi)mainwindow#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include"management.h"namespace Ui class MainWindow;class MainWindow : public QMain
8、Window Q_OBJECTpublic: explicit MainWindow(QWidget *parent = 0); MainWindow();private slots: void on_pushButton_clicked(); void on_ok_clicked(); void on_pushButton_2_clicked(); void on_ok_2_clicked(); void on_ss_clicked(); void on_ss_2_clicked(); void on_pushButton_3_clicked(); void on_pushButton_4_
9、clicked();private: Ui:MainWindow *ui;#endif / MAINWINDOW_H【主界面設(shè)計(jì)】:主機(jī)面主要以一個(gè)do-while循環(huán)使得系統(tǒng)能夠多次查詢(xún)。循環(huán)中大部分是判斷語(yǔ)句的嵌套。能夠以用戶(hù)意愿自由查詢(xún)和進(jìn)出系統(tǒng)?!疚募x到屏幕上】【修改記錄】【添加紀(jì)錄】【刪除記錄】【模糊搜索】【分段搜索】【統(tǒng)計(jì)分析】【排序】四 詳細(xì)設(shè)計(jì)"【增加記錄】:所用函數(shù):addtxt()函數(shù)、itxt()函數(shù)。增加記錄主要是調(diào)用void addtxt()函數(shù)。進(jìn)入void addtxt()函數(shù)后,用戶(hù)經(jīng)過(guò)手動(dòng)添加信息。添加信息過(guò)后,系統(tǒng)會(huì)將用戶(hù)所輸入的信息與數(shù)據(jù)庫(kù)中已
10、有信息進(jìn)行對(duì)比,判斷數(shù)據(jù)庫(kù)中是否已存在該信息。不存在則添加,添加時(shí)會(huì)調(diào)用student類(lèi)的構(gòu)造函數(shù)。用戶(hù)所添加的信息則會(huì)有一個(gè)以類(lèi)型為student的變量push_back到默認(rèn)以student為類(lèi)型的容器中。然后點(diǎn)擊確定轉(zhuǎn)為槽函數(shù),再通過(guò)mainwindow類(lèi)中的指針ui指向text edit,使結(jié)果輸出到text edit上。此時(shí)在經(jīng)過(guò)while循環(huán),使得系統(tǒng)支持重復(fù)添加功能。otxt()函數(shù)將數(shù)據(jù)輸出保存到date.txt文件中?!緞h除記錄】:實(shí)現(xiàn)該功能先要調(diào)用void deletetxt()函數(shù)。進(jìn)入該函數(shù)后系統(tǒng)會(huì)提示用戶(hù)輸入所需刪除信息的學(xué)號(hào)或姓名。然后系統(tǒng)會(huì)在數(shù)據(jù)庫(kù)中搜索是否真的存
11、在此信息。不存在系統(tǒng)會(huì)提示用戶(hù)。若存在則所刪信息會(huì)在對(duì)話框中出現(xiàn)。此時(shí)系統(tǒng)會(huì)調(diào)用void deletetxt()函數(shù)、string getId()函數(shù)、string getName()函數(shù)、 intgetMath()函數(shù)int getEng()函數(shù)、int getPhy()函數(shù)、int total()函數(shù)。然后系統(tǒng)會(huì)提示用戶(hù)確定是否刪除該信息。若否則回到主菜單。若是此時(shí)系統(tǒng)會(huì)定義一個(gè)以student為類(lèi)型的容器。然后默認(rèn)的以student為類(lèi)型的容器(其中有數(shù)據(jù)庫(kù)中的全部信息。)經(jīng)過(guò)兩個(gè)for循環(huán)將數(shù)據(jù)庫(kù)中除了用戶(hù)要?jiǎng)h除的信息全部push_back到定義的容器中。然后再經(jīng)過(guò)一個(gè)for循環(huán)。使得
12、默認(rèn)的容器當(dāng)中的信息與定義的容器當(dāng)中的信息相同。則完成刪除。刪除成功后,通過(guò)mainwindow類(lèi)中指針指向另一個(gè)對(duì)話框此時(shí)對(duì)話框會(huì)提示用戶(hù)刪除成功?!境煽?jī)修改】:先進(jìn)入void changetxt()函數(shù),對(duì)話框中會(huì)提示用戶(hù)輸入所要修改的信息。輸入信息后系統(tǒng)會(huì)定義一個(gè)以student為類(lèi)型的變量。然后系統(tǒng)會(huì)調(diào)用student &operator=(const student &)函數(shù),使得修改后的信息覆蓋掉原有信息。在用mainwindow類(lèi)中的指針ui把結(jié)果輸出到textedit上,在調(diào)用文本輸入的函數(shù)使得用戶(hù)能夠確定信息確實(shí)修改成功了。【查找】:進(jìn)入查找后對(duì)話框中會(huì)提示用
13、戶(hù)是分?jǐn)?shù)段查找還是個(gè)人成績(jī)查詢(xún)。若是前者則系統(tǒng)調(diào)用void findtxt1()函數(shù)。此時(shí)對(duì)話框會(huì)提示用戶(hù)選擇哪一門(mén)成績(jī)以及分?jǐn)?shù)的上下限。然后系統(tǒng)再調(diào)用此時(shí)系統(tǒng)會(huì)調(diào)用void deletetxt()函數(shù)、string getId()函數(shù)、string getName()函數(shù)、 int getMath()函數(shù)int getEng()函數(shù)、int getPhy()函數(shù)、int total()函數(shù)。對(duì)話框中會(huì)出現(xiàn)在此分?jǐn)?shù)段中的所有信息。并回到菜單。若是后者則系統(tǒng)調(diào)用void findtxt()函數(shù)(支持模糊搜索)。此時(shí)對(duì)話框中會(huì)提示用戶(hù)輸入所要尋找的信息的學(xué)號(hào)或姓名。系統(tǒng)會(huì)將數(shù)據(jù)庫(kù)中滿足條件的信息反
14、饋到對(duì)話框中,然后mainwindow類(lèi)中指針ui將返回的容器的成員轉(zhuǎn)化為QString類(lèi)型然后將結(jié)果反饋到text edit上?!窘y(tǒng)計(jì)分析】:現(xiàn)根據(jù)對(duì)話框的提示選擇系統(tǒng)分析欄。對(duì)話框會(huì)提示用戶(hù)是單科情況或是全科情況。若是前者系統(tǒng)會(huì)調(diào)用void ttxt()函數(shù),把結(jié)果反饋到對(duì)話框中并回到主菜單中。若是后者系統(tǒng)調(diào)用void ttxt(int i)函數(shù)。然后把結(jié)果(平均分、總平局分、及格率、標(biāo)準(zhǔn)差)用mainwindow類(lèi)中指針ui轉(zhuǎn)到另一個(gè)對(duì)話框中,在調(diào)用該對(duì)話框中的指針ui將結(jié)果反饋到text edit上?!九判颉浚含F(xiàn)根據(jù)對(duì)話框的提示選擇排序。系統(tǒng)會(huì)調(diào)用void ptxt()函數(shù)。進(jìn)入voi
15、d ptxt()函數(shù)系統(tǒng)會(huì)調(diào)用string getId()函數(shù)、string getName()函數(shù)、 intgetMath()函數(shù)int getEng()函數(shù)、int getPhy()函數(shù)、int total()函數(shù)。根據(jù)總分進(jìn)行排序(從高到低),若總分相同,則按數(shù)學(xué)排序;若總分和數(shù)學(xué)相同,則按物理排序;若總分和各科成績(jī)都相同,則按學(xué)號(hào)排序;排序完成后,mainwindow類(lèi)中指針ui將容器中的信息全部轉(zhuǎn)化為QString類(lèi)型。然后調(diào)用輸出文本將結(jié)果反饋到text edit上。【退出系統(tǒng)】:在主菜單中選擇退出系統(tǒng),系統(tǒng)會(huì)跳出主菜單中的do-while循環(huán),結(jié)束程序。五 測(cè)試【原有數(shù)據(jù)】201
16、21000290 邊達(dá)宇 75 60 65 20121000424 王晨 85 95 9620121000553 高佳維 86 93 9020121000570 初國(guó)利 85 87 8520121000584 利振彬 70 88 8820121000818 孟珂 90 86 96 20121000921 羅云迪 86 90 7520121001121 田甜 95 85 8720121001248 王如男 90 89 9420121001316 邵葉飛 80 84 8620121001375 周晨曦 87 86 9020121001695 王洪 96 88 9120121001842 尹笛露 8
17、5 90 9420121002002 劉宇坤 88 86 9020121002152 尹然宇 82 90 8820121002162 孫史磊 80 94 8020121002269 陳云鍋 83 95 8520121002321 于文濤 88 90 8620121002439 景揭俊 85 92 8520121002585 戴賢鐸 88 86 7820121002685 曹厚臻 90 87 9020121002775 馬晴 93 85 9020121003127 馮澤宇 80 89 7520121003358 肖寒 88 90 9020121003359 張賡 87 95 8420121003
18、398 劉劍峰 88 84 8620121003399 龔方怡 90 93 9620121004233 賈國(guó)棟 88 90 8620121004415 孫一卓 86 95 90六 結(jié)論【總結(jié)】:1. 在設(shè)計(jì)程序時(shí),我們需要對(duì)每個(gè)文件域之間的聯(lián)系了解,包含關(guān)系要明確。每設(shè)計(jì)完成一個(gè)函數(shù)時(shí)我們都要進(jìn)行測(cè)試。確保沒(méi)有語(yǔ)法錯(cuò)誤和邏輯錯(cuò)誤后再進(jìn)行下一個(gè)函數(shù)的設(shè)計(jì)。將函數(shù)編寫(xiě)完之后,再進(jìn)行mian函數(shù)的編寫(xiě)。2. 在設(shè)計(jì)文件讀入與文件輸出時(shí),要保證保存路徑的正確性。通過(guò)此次課設(shè)使得我對(duì)這兩個(gè)知識(shí)點(diǎn)更好的理解與掌握。3. 對(duì)于引用、運(yùn)算符的重載的運(yùn)用更加透徹。意識(shí)到在設(shè)計(jì)當(dāng)中應(yīng)盡量提高系統(tǒng)的效率的重要性。4
19、. 在設(shè)計(jì)模糊搜索和刪除記錄中,使得我對(duì)類(lèi)string中自帶的find函數(shù)與erase函數(shù)的執(zhí)行過(guò)程的理解。5. 此次課設(shè)使我明白了在設(shè)計(jì)時(shí)應(yīng)以謹(jǐn)慎的態(tài)度對(duì)待。不能馬虎粗心。不要太過(guò)心急。遇到困難要冷靜。6. 在做QT可視化時(shí),遇到了許多問(wèn)題。由于對(duì)很多系統(tǒng)自帶的函數(shù)斌不了解,所以花了很多時(shí)間去網(wǎng)上查閱了很多知識(shí)點(diǎn)。也學(xué)到了很多東西。7. 在做彈出對(duì)話框時(shí),用了很多工夫去做這個(gè),但依舊有一些我目前無(wú)法解決的問(wèn)題。8. 為了界面跟家美觀,向同學(xué)請(qǐng)教了如何做背景。然后自己也將畫(huà)面中的字體和顏色改變,但依舊還是有一些不足之處。例如:當(dāng)信息輸出到text edit上,若滑動(dòng)鼠標(biāo)上的滑輪時(shí),背景會(huì)出現(xiàn)斷
20、層現(xiàn)象。七 附錄#ifndef DIALOG_CHAGE_H#define DIALOG_CHAGE_H#include <QDialog>namespace Ui class Dialog_chage;class Dialog_chage : public QDialog Q_OBJECTpublic: explicit Dialog_chage(QWidget *parent = 0); Dialog_chage();private slots: void on_pushButton_clicked();private: Ui:Dialog_chage *ui;#endif /
21、 DIALOG_CHAGE_H#ifndef DIALOG_DELETE_H#define DIALOG_DELETE_H#include <QDialog>namespace Ui class Dialog_delete;class Dialog_delete : public QDialog Q_OBJECTpublic: explicit Dialog_delete(QWidget *parent = 0); Dialog_delete();private: Ui:Dialog_delete *ui;#endif / DIALOG_DELETE_H#ifndef DIALOG
22、_TONGJI_H#define DIALOG_TONGJI_H#include <QDialog>namespace Ui class Dialog_tongji;class Dialog_tongji : public QDialog Q_OBJECTpublic: explicit Dialog_tongji(QWidget *parent = 0); Dialog_tongji();private slots: void on_pushButton_clicked();private: Ui:Dialog_tongji *ui;#endif / DIALOG_TONGJI_
23、H#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include"management.h"namespace Ui class MainWindow;class MainWindow : public QMainWindow Q_OBJECTpublic: explicit MainWindow(QWidget *parent = 0); MainWindow();private slots: void on_pushButton_clicked(); void on_ok_clic
24、ked(); void on_pushButton_2_clicked(); void on_ok_2_clicked(); void on_ss_clicked(); void on_ss_2_clicked(); void on_pushButton_3_clicked(); void on_pushButton_4_clicked();private: Ui:MainWindow *ui;#endif / MAINWINDOW_H#ifndef MANAGEMENT#define MANAGEMENT#include "student.h"#include"
25、QString"#include<QFileDialog>#include<QFile>#include<qtextstream.h>class managementprivate: vector<student>stu;public: vector<student> deletetxt(const string& m); /刪除記錄 vector<student> findtxt(const string& m); /模糊搜索 vector<student> findtxt1(int
26、,int,const string&); /分?jǐn)?shù)段搜索 vector<student> itxt(); /文件寫(xiě)入 vector<student> getstu()return stu; vector<double> ttxt(vector<double>); /統(tǒng)計(jì)分析 vector<student> ptxt(); /排序 void addtxt(); /增加記錄 void changetxt(); /成績(jī)修改 void otxt(); /文件輸出 void show(); /輸出;#endif / MANAGEMENT#
27、ifndef STUDENT_H#define STUDENT_H#include<iostream>#include<vector>#include<fstream>#include<string>#include<iomanip>#include<cmath>using namespace std;class studentprivate: string m_id, m_name; int m_math, m_eng, m_phy;public: student(); student(string, string, i
28、nt, int, int); /構(gòu)造函數(shù) student(const student &); /復(fù)制構(gòu)造函數(shù) student(); / 析構(gòu)函數(shù) string getId(); /自定義接口 string getName(); intgetMath(); int getEng(); int getPhy(); int total(); student operator=(const student &); / =號(hào)重載;#endif / STUDENT_H#include "dialog_chage.h"#include "ui_dialog_ch
29、age.h"#include"management.h"#include<QString>#include<QGraphicsOpacityEffect>Dialog_chage:Dialog_chage(QWidget *parent) : QDialog(parent), ui(new Ui:Dialog_chage) ui->setupUi(this); QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(this); effect->setOpacity
30、(0.4); ui->textEdit->setGraphicsEffect(effect);Dialog_chage:Dialog_chage() delete ui;void Dialog_chage:on_pushButton_clicked() management me; vector<student>v=me.itxt(); string str; student stu; QString Q; Q=ui->lineEdit->text(); str=Q.toStdString(); int i,j,k; int p(0); for(i=0;i&
31、lt;v.size();i+) stu=vi; for(j=0;j<str.size();j+) if(strj!=stu.getId()j) break; if(j=str.size() p+; break; for(k=0;k<str.size();k+) if(strk!=stu.getName()k) break; if(k=str.size() p+; break; if(p=0) ui->textEdit->insertPlainText("沒(méi)有您所修改學(xué)生的信息!"); else student temp(stu.getId(),stu
32、.getName(),ui->lineEdit_2->text().toInt(), ui->lineEdit_3->text().toInt(),ui->lineEdit_4->text().toInt(); vi=temp; ui->textEdit->insertPlainText("修改成功!"); me.otxt();#include "dialog_delete.h"#include "ui_dialog_delete.h"Dialog_delete:Dialog_delet
33、e(QWidget *parent) : QDialog(parent), ui(new Ui:Dialog_delete) ui->setupUi(this);Dialog_delete:Dialog_delete() delete ui;#include "dialog_#h"#include "ui_dialog_#h"#include"management.h"#include"student.h"#include<vector>#include<QGraph
34、icsOpacityEffect>Dialog_tongji:Dialog_tongji(QWidget *parent) : QDialog(parent), ui(new Ui:Dialog_tongji) ui->setupUi(this); ui->textEdit->insertPlainText("確定顯示統(tǒng)計(jì)分析?"); QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(this); effect->setOpacity(0.6); ui->textEdi
35、t->setGraphicsEffect(effect);Dialog_tongji:Dialog_tongji() delete ui;void Dialog_tongji:on_pushButton_clicked() QString qst; ui->textEdit->clear(); management me; ui->textEdit->insertPlainText("科目依次為數(shù)學(xué)、英語(yǔ)、物理。"); ui->textEdit->insertPlainText("前三個(gè)為平均分,中間為及格率,后三個(gè)為標(biāo)準(zhǔn)
36、差"); vector<double>in; in=me.ttxt(in); for(int i=0;i<in.size();i+) qst=QString:number(ini); ui->textEdit->insertPlainText(qst+'n'); #include "mainwindow.h"#include <QApplication>int main(int argc, char *argv) QApplication a(argc, argv); MainWindow w; w.sho
37、w(); return a.exec();#include "mainwindow.h"#include "ui_mainwindow.h"#include"management.h"#include "dialog_chage.h"#include "dialog_delete.h"#include "dialog_#h"#include<QString>#include"student.h"#include<QGraphi
38、csOpacityEffect>#include <QDialog>management me;vector<student>v=me.itxt();QString s2q(const string &s) return QString(QString:fromLocal8Bit(s.c_str(); MainWindow:MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui:MainWindow) ui->setupUi(this); ui->textEdit->set
39、Text(" 歡迎進(jìn)入學(xué)生成績(jī)管理系統(tǒng)!"); QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(this); effect->setOpacity(0.5); ui->label_7->setGraphicsEffect(effect); ui->textEdit->setGraphicsEffect(effect);MainWindow:MainWindow() delete ui;void MainWindow:on_pushButton_clicked() ui-&g
40、t;textEdit->clear(); ui->textEdit->insertPlainText("ID: 姓名:數(shù)學(xué):英語(yǔ): 物理:"); QString a,b,c,d,e,o; student s; for(int i=0;i<v.size();i+) s=vi; a=s2q(s.getId(); b=s2q(s.getName(); c=QString:number(s.getMath(),10); d=QString:number(s.getEng(),10); e=QString:number(s.getPhy(),10); o=a+
41、' '+b+' '+c+' '+d+' '+e+'n' ui->textEdit->insertPlainText(o); void MainWindow:on_ok_clicked() ui->textEdit->clear(); student temp(ui->ID->text().toStdString(),ui->xingming->text().toStdString(),ui->shuxue->text().toInt(), ui->y
42、ingyu->text().toInt(),ui->wuli->text().toInt(); v.push_back(temp); QString a,b,c,d,e,o; a=s2q(temp.getId(); b=s2q(temp.getName(); c=QString:number(temp.getMath(),10); d=QString:number(temp.getEng(),10); e=QString:number(temp.getPhy(),10); o=a+' '+b+' '+c+' '+d+'
43、'+e+'n' ui->textEdit->insertPlainText(o); ui->textEdit->insertPlainText("添加成功!"); me.otxt();void MainWindow:on_pushButton_2_clicked() Dialog_chage * dialog1 = new Dialog_chage(this); dialog1->setWindowTitle(tr("change information"); if(dialog1->exec(
44、)=QDialog:Rejected) return;void MainWindow:on_ok_2_clicked() QString qst=ui->delete_2->text(); string st=qst.toStdString(); v=me.deletetxt(st); ui->delete_2->clear(); Dialog_delete * dialog2 = new Dialog_delete(this); dialog2->setWindowTitle(tr("delete information"); if(dial
45、og2->exec()=QDialog:Rejected) return;void MainWindow:on_ss_clicked() QString qst=ui->sousuo->text(); string str=qst.toStdString(); v=me.findtxt(str); on_pushButton_clicked(); ui->sousuo->clear();void MainWindow:on_ss_2_clicked() QString qst1=ui->kemu->text(); QString qst2=ui->
46、;sousuo1->text(); QString qst3=ui->sousuo2->text(); string str=qst1.toStdString(); int a=qst2.toInt(); int b=qst3.toInt(); v=me.findtxt1(a,b,str); if(v.size() on_pushButton_clicked(); else ui->textEdit->clear(); ui->textEdit->insertPlainText("對(duì)不起!沒(méi)有您所查的信息!"); ui->ke
47、mu->clear(); ui->sousuo1->clear(); ui->sousuo2->clear();void MainWindow:on_pushButton_3_clicked() Dialog_tongji * dialog3 = new Dialog_tongji(this); dialog3->setWindowTitle(tr("tongji information"); if(dialog3->exec()=QDialog:Rejected) return;void MainWindow:on_pushBut
48、ton_4_clicked() v=me.ptxt(); on_pushButton_clicked();#include"management.h"#include<cmath>void management:addtxt() /增加記錄 string id, name; int math, eng, phy,m; int p(0); while(1) cout << "請(qǐng)輸入您所添加的信息:" << endl; cin >> id >> name >> math >>
49、 eng >> phy; student s(id, name, math, eng, phy); for(int i=0;i<stu.size();i+) if(s.getId()=stui.getId()&&(s.getName()=stui.getName() cout<<"數(shù)據(jù)庫(kù)已有此人!不能再添加!"<<endl; p+; if(p=0) stu.push_back(s); otxt(); cout<<"是否繼續(xù)增加? (繼續(xù)回復(fù)1。否則回復(fù)0.)"<<endl;
50、 cin>>m; if(m=0) break; vector<student> management:itxt() /文件寫(xiě)入 ifstream ifile; ifile.open("F:data.txt"); string id, name; int math, eng, phy; do ifile>>id>>name>>math>>eng>>phy; student s(id, name, math, eng, phy); stu.push_back(s); while (!ifile.
51、eof(); ifile.close(); return stu;void management:otxt() /文件輸出 ofstream ofile; ofile.open("F:date.txt"); for (int i=0; i<stu.size();i+) ofile<<setw(20)<<stui.getId()<<setw(6)<<stui.getName()<<setw(6)<<stui.getMath()<<setw(6)<<stui.getEng()&
52、lt;<setw(6)<<stui.getPhy()<<endl; ofile.close();vector<student> management:findtxt(const string& m) /模糊搜索 vector<student>s; int p(0),q(0); int i,j,k; for(i=0;i<stu.size();i+) for(j=0;j<m.size();j+) if(mj!=stui.getId()j) break; if(j=m.size() s.push_back(stui); for(k=0;k<m.size();k+) if(mk!=stui.getName()k) break; if(k=m.size() s.push_back(stui); return s;vector<student> management:findtxt1(int a,int b
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 高一語(yǔ)文下學(xué)期家長(zhǎng)溝通計(jì)劃
- 毛筆書(shū)法基礎(chǔ)訓(xùn)練計(jì)劃
- 造價(jià)公司勞動(dòng)合同協(xié)議
- 特價(jià)供貨協(xié)議書(shū)
- 家電產(chǎn)品維護(hù)與保養(yǎng)計(jì)劃
- 軋機(jī)配件采購(gòu)合同協(xié)議
- 一年級(jí)語(yǔ)文期末復(fù)習(xí)備考計(jì)劃
- 2025年中國(guó)三九胃泰顆粒市場(chǎng)調(diào)查研究報(bào)告
- 2025-2030年中國(guó)合成橡膠和纖維行業(yè)市場(chǎng)現(xiàn)狀供需分析及投資評(píng)估規(guī)劃分析研究報(bào)告
- 2025-2030年中國(guó)農(nóng)村金融行業(yè)市場(chǎng)深度調(diào)研及發(fā)展的政策建議與策略研究報(bào)告
- 《加拉帕戈斯群島》課件
- 2024人教版新教材初中物理八年級(jí)下冊(cè)內(nèi)容解讀課件(深度)
- 工程經(jīng)濟(jì)學(xué)(青島理工大學(xué))知到智慧樹(shù)章節(jié)測(cè)試課后答案2024年秋青島理工大學(xué)
- (高清版)DB2201∕T 43-2023 肉犢牛飼養(yǎng)技術(shù)規(guī)范
- 2025年醫(yī)院消化內(nèi)科年度工作計(jì)劃
- 水資源應(yīng)急調(diào)度模型-洞察分析
- DB51-T 3000-2023 退役軍人服務(wù)站建設(shè)與運(yùn)行管理規(guī)范
- 神經(jīng)指南:中國(guó)成人失眠診斷與治療指南(2017版)
- 代理商合作條件說(shuō)明
- GB/T 15843.2-2024網(wǎng)絡(luò)安全技術(shù)實(shí)體鑒別第2部分:采用鑒別式加密的機(jī)制
- 完整版:美制螺紋尺寸對(duì)照表(牙數(shù)、牙高、螺距、小徑、中徑外徑、鉆孔)
評(píng)論
0/150
提交評(píng)論