




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上程序設計報告基于Linux系統(tǒng)的學生信息管理系統(tǒng)功能:在Linux系統(tǒng)下,實現(xiàn)學生信息的管理功能開發(fā)環(huán)境:Linux Ubuntu 12.04,Intel 64位處理器開發(fā)語言:C語言運行環(huán)境:普通PC機編譯環(huán)境:gcc Makefile本系統(tǒng)對學生信息進行管理,分有學生、老師、老板三種板塊,不同權限的用戶登錄會進入不同的界面進行操作。系統(tǒng)主界面分為注冊,登錄,忘記密碼,關于以及退出,如果沒有這個系統(tǒng)的賬號和密碼可以進行注冊,注冊時候會問你要注冊的權限是什么,并且根據(jù)你注冊的權限進去相應的界面。登錄時候需要輸入賬號以及密碼,如果賬號密碼均正確將進入賬號所屬權限的界面;
2、如果有錯誤,會根據(jù)錯誤類型提醒用戶。忘記密碼可通過管理員用戶查看進行找回。關于則是一點具體信息。退出則會退出此程序。以下具體介紹每個權限中的具體功能:1. 學生界面:學生的功能包括查看學生信息,考試,提交試卷,修改密碼,返回以及退出的功能。將各個函數(shù)封裝成一個box,然后在主函數(shù)中進行調(diào)用,具體代碼如下:box中的各函數(shù):#include "stu_box.h"#include <stdio.h>#include <stdlib.h>#include <string.h>static void init_node(struct stu_i
3、nfo *head, struct stu_info info)strcpy(head->name, );strcpy(head->sex, info.sex);head->age = info.age;strcpy(head->cid, info.cid);strcpy(head->tel, info.tel);strcpy(head->addr, info.addr);strcpy(head->object, info.object);head->next = head;head->prev = head;static
4、 void _add(struct stu_info *a, struct stu_info *new, struct stu_info *b)a->next = new;new->next = b;b->prev = new;new->prev = a;static int add(struct stu_info *head, struct stu_info info)struct stu_info *new = NULL;new = (struct stu_info *)malloc(sizeof(struct stu_info);init_node(new, in
5、fo);_add(head, new, head->next);return 1;static int read_from_stdin(struct stu_box *box)struct stu_info *head = box->head;struct stu_info info;printf("tttttt請輸入學生信息:n");printf("tttttt例如:張山 男 23 上海市 嵌入式ntttttt");scanf("%s %s %d %s %s %s %s", , info.sex, &a
6、mp;info.age, info.cid, info.tel, info.addr, info.object);add(head, info);return 1;static int read_from_file(struct stu_box *box)struct stu_info *head = box->head;struct stu_info info;/1.fopenFILE *fp = NULL;fp = fopen("dat/stu_info.dat", "r+");if(fp = NULL)perror("fopen&q
7、uot;);return -1;while( (fscanf(fp, "%s %s %d %s %s %s %s", , info.sex, &info.age, info.cid, info.tel, info.addr, info.object) != EOF)add(head, info);fclose(fp);return 0;static int edit(struct stu_box *box)return 1;static int display(struct stu_box *box)struct stu_info *tmp = b
8、ox->head;for(tmp = box->head->next; tmp != box->head; tmp= tmp->next)printf("tttt%st%st%dt%st%st %st%sn", tmp->name, tmp->sex, tmp->age, tmp->cid, tmp->tel, tmp->addr, tmp->object);return 1;static void init_head(struct stu_info *head)struct stu_info info
9、 = "abc", "男", 22, "", "", "上海市", "嵌入式"init_node(head, info);static int del(struct stu_box *box)char name32;printf("tttttt請輸入需要刪除學生的姓名:ntttttt");scanf("%s", name);struct stu_info *tmp = box->head;for(tmp = box->hea
10、d->next; tmp != box->head; tmp= tmp->next)if(strcmp(tmp->name, name) = 0)tmp->prev->next = tmp->next;tmp->next->prev = tmp->prev;init_head(tmp);free(tmp);break;return 1;static int save(struct stu_box *box)struct stu_info *head = box->head;struct stu_info *tmp = NULL;
11、/1.打開文件FILE *fp = NULL;fp = fopen("dat/stu_info.dat","w+");if(fp = NULL)perror("fopen()");return -1;for(tmp = head->next; tmp != head; tmp = tmp->next)/2.往文件里面寫入fprintf(fp, "%s %s %d %s %s %s %sn", tmp->name, tmp->sex, tmp->age, tmp->cid, tmp
12、->tel, tmp->addr, tmp->object);/3.關閉文件fclose(fp);return 0; struct stu_box *init_stu_box()struct stu_box *box = NULL;box = (struct stu_box *)malloc(sizeof(struct stu_box);/創(chuàng)建鏈表struct stu_info *head = NULL;head = (struct stu_info *)malloc(sizeof(struct stu_info);init_head(head);box->head =
13、 head;box->edit = edit;box->del = del;box->display = display;box->save = save;box->readin = read_from_stdin;box->readfp = read_from_file;return box;主函數(shù):#include "user_box.h"#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <time.h>#i
14、nclude "user.h"#include "stu_box.h"static void display_menu()/system("clear");printf("tttttt*n");printf("tttttt* *n");printf("tttttt* 1. 查看學生信息 *n");printf("tttttt* 2. 考試 *n");printf("tttttt* 3. 提交試卷 *n");printf("tt
15、tttt* 4. 修改密碼 *n");printf("tttttt* 5. 返回 *n");printf("tttttt* 0. 退出 *n");printf("tttttt* *n");printf("tttttt*n");void display_stu_info(struct stu_box *box)box->readfp(box);system("clear");printf("nnnnn");printf("tttt *學生信息* n&q
16、uot;);printf("nntttt+n");box->display(box);printf("tttt+n");box->save(box);/考試int test()/printf("_%s_n", _func_);char path32;printf("tttttt請輸入存放試卷的路徑:ntttttt");scanf("%s", path);/getchar();FILE *fp_s = NULL;fp_s = fopen("dat/test.txt"
17、, "r+");if(fp_s = NULL)perror("fopen():fp_s");return -1;FILE *fp_d = NULL;fp_d = fopen(path, "w+");if(fp_d = NULL)perror("fopen():fp_d");return -1;char c;while( (c = fgetc(fp_s) != EOF)fputc(c, fp_d);fclose(fp_s);fclose(fp_d);return 0;/提交試卷int upload(struct us
18、er *u)char path32;printf("tttttt請輸入存放答案的路徑:ntttttt");scanf("%s", path);FILE *fp_s = NULL;fp_s = fopen(path, "r+");if(fp_s = NULL)perror("fopen():fp_s");return -1;char str32;sprintf(str, "%s%s%s", "dat/", u->name, "_ret.txt");FI
19、LE *fp_d = NULL;fp_d = fopen(str, "w+");if(fp_d = NULL)perror("fopen():fp_d");return -1;char c;while( (c = fgetc(fp_s) != EOF)fputc(c, fp_d);fclose(fp_s);fclose(fp_d);return 0;/修改密碼int mod_pd()struct user_info_box * box1= init_user_box();box1->readfp(box1);box1->chmm(box1);
20、box1->save(box1);return 0;int stu_main(struct user *u)/struct user_info_box *box1= init_user_box();struct stu_box *box = init_stu_box();int ret;int y = 0;while(y = 0)system("clear");printf("nnnntttttt 歡迎進入學生界面 nn");time_t t;t = time(NULL);struct tm *tm = localtime(&t);char
21、 ts20;sprintf(ts,"%04d-%02d-%02d-%02d:%02d:%02d",tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,tm->tm_hour, tm->tm_min,tm->tm_sec);printf("tttttt歡迎%s登錄 %sn", u->name,ts);display_menu();printf("tttttt請選擇:");scanf("%d", &ret);getchar()
22、;switch(ret)case 1:/查看學生信息box->readfp(box);display_stu_info(box);box->save(box);preAnyone();break;case 2:/考試if(test()=0)printf("tttttt抽取試卷成功!n");preAnyone();elseprintf("tttttt抽取試卷失??!n");preAnyone();break;case 3:/提交試卷upload(u);break;case 4/修改密碼mod_pd();preAnyone();break;case
23、 5:y = 6;break;case 0:exit(0);break;default:printf("tttttt您的輸入有誤!n");preAnyone();break;return 0;2. 老師界面老師的功能包括編輯學生信息,上傳試卷,批改試卷,修改密碼,返回以及退出的功能。其中編輯學生信息又分為查看學生信息,增加學生信息,修改學生信息以及刪除學生信息,具體代碼實現(xiàn)如下:#include<time.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#in
24、clude "user.h"#include "stu_box.h"#include "user_box.h"static void display_menu()/system("clear");printf("tttttt*n");printf("tttttt* - *n");printf("tttttt* |1. 編輯學生信息| *n");printf("tttttt* |2. 上傳試卷 | *n");printf("tt
25、tttt* |3. 批改試卷 | *n");printf("tttttt* |4. 修改密碼 | *n");printf("tttttt* |5. 返回 | *n");printf("tttttt* |0. 退出 | *n");printf("tttttt* - *n");printf("tttttt*n");static int display_edit_stu_menu()int y =0;int ret;struct stu_box *box = init_stu_box();b
26、ox->readfp(box);while(y =0)system("clear");printf("nnnn");printf("tttttt 學生編輯 nn");printf("tttttt*n");printf("tttttt* - *n");printf("tttttt* |1.查看學生信息| *n");printf("tttttt* |2.增加學生信息| *n");printf("tttttt* |3.修改學生信息| *n&quo
27、t;);printf("tttttt* |4.刪除學生信息| *n");printf("tttttt* |5.返回 | *n");printf("tttttt* |0.退出 | *n");printf("tttttt* - *n");printf("tttttt*n");printf("tttttt請輸入你的選擇:");scanf("%d", &ret);getchar();switch(ret)case 1:box->display(box
28、);preAnyone();break;case 2:box->readin(box);getchar();preAnyone();break;case 3:box->edit(box);getchar();preAnyone();break;case 4:box->del(box);getchar();preAnyone();break;case 5:y = 5;break;case 0:/保存文件box->save(box);exit(0);default:break;/保存文件box->save(box);return 0;void edit_stu_inf
29、o()display_edit_stu_menu();/考試static int test()char path32;printf("tttttt請輸入存放試卷的路徑:ntttttt");scanf("%s", path);FILE *fp_s = NULL;fp_s = fopen("dat/test.txt", "r+");if(fp_s = NULL)perror("fopen():fp_s");return -1;FILE *fp_d = NULL;fp_d = fopen(path,
30、"w+");if(fp_d = NULL)perror("fopen():fp_d");return -1;char c;while( (c = fgetc(fp_s) != EOF)fputc(c, fp_d);fclose(fp_s);fclose(fp_d);return 0;/提交試卷static int upload(struct user *u)char path32;printf("tttttt請輸入存放答案的路徑:ntttttt");scanf("%s", path);FILE *fp_s = NULL;fp_s = fopen(path, "r+");if(fp_s = NULL)perror("fopen():fp_s");return -1;char str32;sprintf(str, "%s%s%s", "dat/", u->name, "_ret.txt"
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權】 IEC TS 63346-1-1:2024 EN Low-voltage auxiliary power systems - Part 1-1: Terminology
- 【正版授權】 IEC 62386-105:2024 EN-FR Digital addressable lighting interface - Part 105: Particular requirements for control gear and control devices - Firmware transfer
- 【正版授權】 ISO/IEC TR 19583-24:2025 EN Information technology - Concepts and usage of metadata - Part 24: 11179-3:2013 Metamodel in RDF
- 2025-2030年中國鋅系常溫磷化液市場運營現(xiàn)狀與發(fā)展前景分析報告
- 2025-2030年中國釩鐵行業(yè)市場經(jīng)營狀況及投資戰(zhàn)略研究報告
- 2025江西省安全員B證(項目經(jīng)理)考試題庫
- 2025-2030年中國軟體家具市場運行態(tài)勢及發(fā)展趨勢分析報告
- 2025-2030年中國貝復舒行業(yè)前景展望及未來投資規(guī)劃研究報告
- 2025-2030年中國蛋品加工市場運營狀況及發(fā)展趨勢分析報告
- 2025-2030年中國管道管產(chǎn)業(yè)前景趨勢及投資戰(zhàn)略研究報告
- lm3s8962開發(fā)板用戶手冊
- IATF16949-過程審核檢查表-(含審核記錄)-
- 食品防護評估表
- 編輯出版史考試重點整理
- (74)-17.3手性高效液相色譜法
- 淺談新生兒肺透明膜病的影像學診斷
- SMT失效模式分析PFMEA
- 國際貿(mào)易地理全套課件
- 家校共育-助孩子成長-家長會課件
- 叉形件工藝及車床夾具設計說明書
- GB/T 5916-2008產(chǎn)蛋后備雞、產(chǎn)蛋雞、肉用仔雞配合飼料
評論
0/150
提交評論