當前位置:首頁 » 考試成績 » c數據結構學生成績管理系統

c數據結構學生成績管理系統

發布時間: 2021-01-20 23:07:15

A. 數據結構(學生成績管理系統)

http://wenku..com/view/dc69e8ef5ef7ba0d4a733bff.html

B. 數據結構課程設計:學生成績管理系統(C++和C),求大神幫幫忙,求代碼

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
structSTUDENT{
floatscore[3];
longid;
charnames[20];
};
typedefstructSTUDENTstudent;//simplifythestructSTUDENT
typedefstructSTUDENT*Pstudent;

voidprint();
voidappend();
voidcourse_total();
voidstudent_total();
voidscore_sort(int(*compare)(floata,floatb));
voidnumber_sort();
voidname_sort(Pstudentnames_[30]);
voidnumber_search();
voidname_search();
voidstatistic(Pstudentscores_[30]);

voidshow(inti);

intascend(floata,floatb){
if(a>b)return1;
elsereturn0;
}
intdescend(floata,floatb){
if(a<b)return1;
elsereturn0;
}
intn;//thenumberofstudents

intflg=1;//trueprinttheresult
student*stuArray[30];//

intagain=1;//whethertocontinue
intmain(){
inti;
printf("Inputstudentnumber(n<30):");
scanf("%d",&n);
intchoice;
while(again){
print();
scanf("%d",&choice);
switch(choice){
case1:
append();
break;
case2:
course_total();//useflagtodefinewhethertoprint
break;
case3:
student_total();
break;
case4:
score_sort(descend);
if(flg){
printf(": ");
printf("NO Name MT EN PH SUM AVER ");
for(i=0;i<n;i++)
show(i);
}
break;
case5:
score_sort(descend);
if(flg){
printf(": ");
printf("NO Name MT EN PH SUM AVER ");
for(i=0;i<n;i++)
show(n-1-i);
}
break;
case6:
number_sort();
break;
case7:
name_sort(stuArray);
break;
case8:
number_search();
break;
case9:
name_search();
break;
case10:
statistic(stuArray);
break;
case0:
again=0;
printf("Endofprogram! ");
break;
default:
printf("Inputerror! ");
break;
}

}
return0;
}

voidprint(){
printf("1.Appendrecord ");
printf("2. ");
printf("3. ");
printf("4. ");
printf("5. ");
printf("6.Sortinascendingorderbynumber ");
printf("7.Sortindictionaryorderbyname ");
printf("8.Searchbynumber ");
printf("9.Searchbyname ");
printf("10.Statisticanalysis ");
printf("PleaseInputyourchoice:");
}
voidappend(){
inti;
printf("Inputstudent'sID,nameandscore: ");
for(i=0;i<n;i++){////
stuArray[i]=(student*)malloc(sizeof(student));
scanf("%ld%s",&stuArray[i]->id,stuArray[i]->names);
scanf("%f",&stuArray[i]->score[0]);
scanf("%f",&stuArray[i]->score[1]);
scanf("%f",&stuArray[i]->score[2]);
}
}
voidcourse_total(){
inti;
floatsum0=0.0,sum1=0.0,sum2=0.0;
for(i=0;i<n;i++){
sum0+=stuArray[i]->score[0];
sum1+=stuArray[i]->score[1];
sum2+=stuArray[i]->score[2];
}
if(flg){
printf("course%d:sum=%.0f,aver=%.0f ",1,sum0,sum0/n);
printf("course%d:sum=%.0f,aver=%.0f ",2,sum1,sum1/n);
printf("course%d:sum=%.0f,aver=%.0f ",3,sum2,sum2/n);
}
}
voidstudent_total(){
floattotal[30]={0.0};
inti;
for(i=0;i<n;i++){
total[i]=stuArray[i]->score[0]+stuArray[i]->score[1]+stuArray[i]->score[2];
}
if(flg){
for(i=0;i<n;i++)
printf("student%d:sum=%.0f,aver=%.0f ",i+1,total[i],total[i]/3);
}
}
voidscore_sort(int(*compare)(floata,floatb)){
inti,j;
floattotal[30]={0.0};
for(i=0;i<n;i++){
total[i]=stuArray[i]->score[0]+stuArray[i]->score[1]+stuArray[i]->score[2];
}
for(i=0;i<n;i++){
for(j=0;j<=i;j++)
//if((*compare)(stuArray[i]->score[0]+stuArray[i]->score[1]+stuArray[i]->score[2],stuArray[j]->score[0]+stuArray[j]->score[1]+stuArray[j]->score[2])==0){
if((*compare)(total[i],total[j])==0){//
student*tmp=(student*)malloc(sizeof(student));
memcpy(tmp,stuArray[i],sizeof(student));
memcpy(stuArray[i],stuArray[j],sizeof(student));
memcpy(stuArray[j],tmp,sizeof(student));
}//memcpy->theholethememory
}

}
voidnumber_sort(){//沒必要傳參
inti,j;
for(i=0;i<n;i++){
for(j=0;j<i;j++)
if(stuArray[i]->id<stuArray[j]->id){
student*tmp=(student*)malloc(sizeof(student));
memcpy(tmp,stuArray[i],sizeof(student));
memcpy(stuArray[i],stuArray[j],sizeof(student));
memcpy(stuArray[j],tmp,sizeof(student));
}
}
if(flg){
printf("Sortinascendingorderbynumber: ");
printf("NO Name MT EN PH SUM AVER ");
for(i=0;i<n;i++)
show(i);
}
}
voidname_sort(Pstudentnames_[30]){
inti,j;
for(i=0;i<n;i++){
for(j=0;j<=i;j++)
if(strcmp(names_[i]->names,names_[j]->names)<0){
student*tmp=(student*)malloc(sizeof(student));
memcpy(tmp,stuArray[i],sizeof(student));
memcpy(stuArray[i],stuArray[j],sizeof(student));
memcpy(stuArray[j],tmp,sizeof(student));
}
}
if(flg){
printf("Sortindictionaryorderbyname: ");
printf("NO Name MT EN PH SUM AVER ");
for(i=0;i<n;i++)
show(i);
}
}
voidnumber_search(){
longquery;
printf("Inputthenumberyouwanttosearch:");
scanf("%ld",&query);
inti;
score_sort(descend);//1009887
for(i=0;i<n;i++){
if(stuArray[i]->id==query)
break;
}
if(i!=n){
printf("%d ",i+1);
show(i);
}
else
printf("Notfound! ");
}
voidname_search(){
charquery[20];
score_sort(descend);
printf("Inputthenameyouwanttosearch:");
scanf("%s",query);
inti;
for(i=0;i<n;i++){
if(!strcmp(query,stuArray[i]->names)){
break;
}
}
if(i!=n){
printf("%d ",i+1);
show(i);
}
else
printf("Notfound! ");
}
voidstatistic(Pstudentscores_[30]){//apointerarraystandsforscores
floatMT[30],EN[30],PH[30];
inti;
for(i=0;i<n;i++){
MT[i]=scores_[i]->score[0];
EN[i]=scores_[i]->score[1];
PH[i]=scores_[i]->score[2];
}
intsta[6]={0};//(<60or60-70....)
for(i=0;i<n;i++){
if(MT[i]<60)
sta[0]++;
if(MT[i]==100)
sta[5]++;
if(MT[i]>=60&&MT[i]<=69)
sta[1]++;
if(MT[i]>=70&&MT[i]<=79)
sta[2]++;
if(MT[i]>=80&&MT[i]<=89)
sta[3]++;
if(MT[i]>=90&&MT[i]<=100)
sta[4]++;
}

if(flg){
printf("Forcourse%d: ",1);
printf("<60 %d %.2f%% ",sta[0],sta[0]/(float)n*100);//changentofloat
printf("60-69 %d %.2f%% ",sta[1],sta[1]/(float)n*100);
printf("70-79 %d %.2f%% ",sta[2],sta[2]/(float)n*100);
printf("80-89 %d %.2f%% ",sta[3],sta[3]/(float)n*100);
printf("90-100 %d %.2f%% ",sta[4],sta[4]/(float)n*100);
printf("100 %d %.2f%% ",sta[5],sta[5]/(float)n*100);
}
memset(sta,0,6*sizeof(int));//initializethestaarray
for(i=0;i<n;i++){
if(EN[i]<60)
sta[0]++;
if(EN[i]==100)
sta[5]++;
if(EN[i]>=60&&EN[i]<=69)
sta[1]++;
if(EN[i]>=70&&EN[i]<=79)
sta[2]++;
if(EN[i]>=80&&EN[i]<=89)
sta[3]++;
if(EN[i]>=90&&EN[i]<=100)
sta[4]++;
}

if(flg){
printf("Forcourse%d: ",2);
printf("<60 %d %.2f%% ",sta[0],sta[0]/(float)n*100);//changentofloat
printf("60-69 %d %.2f%% ",sta[1],sta[1]/(float)n*100);
printf("70-79 %d %.2f%% ",sta[2],sta[2]/(float)n*100);
printf("80-89 %d %.2f%% ",sta[3],sta[3]/(float)n*100);
printf("90-100 %d %.2f%% ",sta[4],sta[4]/(float)n*100);
printf("100 %d %.2f%% ",sta[5],sta[5]/(float)n*100);
}
memset(sta,0,6*sizeof(int));
for(i=0;i<n;i++){
if(PH[i]<60)
sta[0]++;
if(PH[i]==100)
sta[5]++;
if(PH[i]>=60&&PH[i]<=69)
sta[1]++;
if(PH[i]>=70&&PH[i]<=79)
sta[2]++;
if(PH[i]>=80&&PH[i]<=89)
sta[3]++;
if(PH[i]>=90&&PH[i]<=100)
sta[4]++;
}

if(flg){
printf("Forcourse%d: ",3);
printf("<60 %d %.2f%% ",sta[0],sta[0]/(float)n*100);//changentofloat
printf("60-69 %d %.2f%% ",sta[1],sta[1]/(float)n*100);
printf("70-79 %d %.2f%% ",sta[2],sta[2]/(float)n*100);
printf("80-89 %d %.2f%% ",sta[3],sta[3]/(float)n*100);
printf("90-100 %d %.2f%% ",sta[4],sta[4]/(float)n*100);
printf("100 %d %.2f%% ",sta[5],sta[5]/(float)n*100);
}
}

voidshow(inti){

printf("%ld %s ",stuArray[i]->id,stuArray[i]->names);//orderistheidaftersort
printf("%.0f %.0f %.0f ",stuArray[i]->score[0],stuArray[i]->score[1],stuArray[i]->score[2]);
floatsum=stuArray[i]->score[0]+stuArray[i]->score[1]+stuArray[i]->score[2];
printf("%.0f %.0f ",sum,sum/3);
}

C. 數據結構鏈表c語言建立學生成績管理系統

#include<stdio.h>
#include<memory.h>
#include<stdlib.h>
#include<string.h>

typedefstructdata{
intnumber;
charname[20];
charid[20];
doublescore[3];
}dataType;

typedefstructlist{
dataTypepauline;
structlist*next;
}*LinkList,*pNode,Node;

void*getMemory(size_tsize){
returnmalloc(size);
}

LinkListgetEmptyList(){
LinkListhead=(pNode)getMemory(sizeof(Node));
memset(head,0,sizeof(Node));
returnhead;
}

intaddNode(LinkListhead,pNodepnode){
pNodeq;
for(q=head;q->next;q=q->next)
if(q->next->pauline.number==pnode->pauline.number){
printf("重復的學號:%d ",pnode->pauline.number);
return0;
}
q->next=pnode;
pnode->next=NULL;
return1;
}

//按學號升排序
voidsortNumber(LinkListhead){
pNodep,q,pt,qt;
p=head;
while(p->next){
qt=p;
q=p->next;
while(q->next){
if(qt->next->pauline.number>q->next->pauline.number)
qt=q;
q=q->next;
}
if(qt!=p){
pt=p->next;
p->next=qt->next;
qt->next=qt->next->next;
p->next->next=pt;
}
p=p->next;
}
}

//按第th門成績降排序,th=1,2,3
voidsortScore(LinkListhead,intth){
pNodep,q,pt,qt;
inti;
if(th<1||th>3)return;
i=th-1;
for(p=head;p->next;p=p->next){
qt=p;
q=p->next;
while(q->next){
if(qt->next->pauline.score[i]<q->next->pauline.score[i])
qt=q;
q=q->next;
}
if(qt!=p){
pt=p->next;
p->next=qt->next;
qt->next=qt->next->next;
p->next->next=pt;
}
}
}

voidshow(LinkListhead){
pNodep;
for(p=head->next;p;p=p->next ){
printf("%d %s %s %.2lf %.2lf %.2lf ",
p->pauline.number,p->pauline.name,p->pauline.id,
p->pauline.score[0],p->pauline.score[1],p->pauline.score[2]);
}
}

pNodereadData(){
pNodepnode=(pNode)getMemory(sizeof(Node));
inti;
printf("學號:");
scanf("%d",&pnode->pauline.number);
printf("姓名:");
scanf("%s",pnode->pauline.name);
printf("身份證:");
scanf("%s",pnode->pauline.id);
for(i=0;i<3;++i){
printf("第%d門成績:",i+1);
scanf("%lf",&pnode->pauline.score[i]);
}
returnpnode;
}

voidmenu(){
printf("******************************** ");
printf("******學生成績管理系統****** ");
printf("******************************** ");
printf("*1、添加學生信息* ");
printf("*2、顯示學生信息* ");
printf("*3、按學號排序* ");
printf("*4、按成績排序* ");
printf("******************************** ");
printf("*0、退出* ");
printf("******************************** ");
}

intmain(){
charop[20];
intselect;
LinkListhead=getEmptyList();
do{
menu();
printf("請選擇:");
fflush(stdin);
fgets(op,20,stdin);
fflush(stdin);
switch(op[0]-'0'){
case1:addNode(head,readData());break;
case2:show(head);break;
case3:sortNumber(head);break;
case4:printf("按第幾門功課排序;");
scanf("%d",&select);
sortScore(head,select);
break;
}
}while(op[0]-'0');
printf("END ");
return0;
}

D. 數據結構用C語言編寫學生成績管理系統

我上個學期的實習作業,要求基本一樣,不過你還是要改改的

E. 求c語言版數據結構課題 學生成績管理系統的程序

|#include<stdio.h>
#include"malloc.h"
#include"string.h"
struct stu{
char name[20];
char stuno[10];
int yw;
int sx;
int yy;
};
struct link{
stu *astu;
link *next;
};
void printfile(link *head,char *s)
{
FILE *p=fopen(s,"w");
link *temp=head;
fprintf(p,"姓名\t學號\t語文\t數學\t英語\n");
while(temp->next!=NULL)
{
temp=temp->next;
fprintf(p,"%s\t%s\t%d\t%d\t%d\n",temp->astu->name,temp->astu->stuno,temp->astu->yw,temp->astu->sx,temp->astu->yy);
}
fclose(p);
}
link *getlink(char *s)
{
FILE *p=fopen(s,"r");
link *head=(link *)malloc(sizeof(link));
int pf;
head->astu=NULL;
head->next=NULL;
link *tail=head;
stu *temp;
fseek(p,sizeof("姓名\t學號\t語文\t數學\t英語\n"),0);
while(!feof(p))
{
pf=ftell(p);
temp=(stu *)malloc(sizeof(stu));
fscanf(p,"%s\t%s\t%d\t%d\t%d\n",temp->name,temp->stuno,&(temp->yw),&(temp->sx),&(temp->yy));
if(pf==ftell(p))break;
tail->next=(link *)malloc(sizeof(link));
tail=tail->next;
tail->astu=temp;
tail->next=NULL;
}
fclose(p);
return head;
}
int allscore(stu *astu)
{
return astu->sx+astu->yw+astu->yy;
}
bool fail(stu *astu)
{
return astu->sx<60||astu->yw<60||astu->yw<60;
}
link *input(char *s)
{
link *head=(link *)malloc(sizeof(link));
head->astu=NULL;
head->next=NULL;
link *tail=head;
stu *temp;
while(true)
{
temp=(stu *)malloc(sizeof(stu));
printf("請輸入學生姓名或者輸入0結束:");
scanf("%s",temp->name);
if(strcmp(temp->name,"0")==0)break;
printf("請輸入學生學號:");
scanf("%s",temp->stuno);
printf("請輸入學生語文成績:");
scanf("%d",&(temp->yw));
printf("請輸入學生數學成績:");
scanf("%d",&(temp->sx));
printf("請輸入學生英語成績:");
scanf("%d",&(temp->yy));
tail->next=(link *)malloc(sizeof(link));
tail=tail->next;
tail->astu=temp;
tail->next=NULL;
}
printfile(head,s);
printf("已成功保存至文件%中\n",s);
return head;
}
void main()
{
link *p1,*p2,*p3,*p4,*temp1,*temp2,*temp3,*temp4;
stu *temp;
printf("請輸入1.txt中的數據:\n");
input("1.txt");
printf("請輸入2.txt中的數據:\n");
input("2.txt");
char s[20];
p1=getlink("1.txt");
p2=getlink("2.txt");
temp1=p1;
while(temp1->next!=NULL)temp1=temp1->next;
temp1->next=p2->next;
for(temp1=p1->next;temp1!=NULL;temp1=temp1->next)
for(temp2=temp1->next;temp2!=NULL;temp2=temp2->next)
if(allscore(temp1->astu)<allscore(temp2->astu))
{
temp=temp1->astu;
temp1->astu=temp2->astu;
temp2->astu=temp;
}
printfile(p1,"3.txt");
temp1=p1;
for(temp2=p1->next;temp2!=NULL;temp2=temp2->next)
if(fail(temp2->astu))
{
temp1->next=temp2;
temp1=temp2;
}
temp1->next=NULL;
printfile(p1,"4.txt");
p1=getlink("3.txt");
printf("結果已保存至文件\n");
printf("請輸入要尋找的學生姓名:");
scanf("%s",s);
for(temp1=p1->next;temp1!=NULL;temp1=temp1->next)
if(strcmp(temp1->astu->name,s)==0)
printf("%s\t%s\t%d\t%d\t%d\n",temp1->astu->name,temp1->astu->stuno,temp1->astu->yw,temp1->astu->sx,temp1->astu->yy);
}

F. 數據結構課程設計--學生成績管理系統C語言

一、需求分析
1. 系統菜單的主要功能
(1)輸入若干條記錄
(2)查找並修改記錄
(3)查找並刪除記錄
(4)成績排序
(5)查找並顯示一條記錄
(6)將數據載入內存中
(7)將所有數據寫入文件中
(0)退出程序
2. 功能分析
功能1為輸入一條記錄到結構體中去。
功能2、3和5演算法相似,都是先查找成績,2、3在此基礎上再對查找出的信息進行操作。因為學生姓名定義成了字元數組的形式,因此在運用選擇法進行排序的時候,要用到strcmp,strcpy等函數
功能4為成績排序,可按學生學號排序或某單科成績或總分排序,並輸出相關的學生信息等。
功能6和7是對文件的操作,提前准備好數據。
二、總體設計
「學生成績管理系統」包括:成績錄入、修改、刪除、成績統計和信息保存、載入這幾個模塊。
1、 主函數 main()
利用無限次循環while(1)和swithch()實現各函數的調用,系統根據輸入的數字選項來調用相應的函數。
2、 菜單選擇函數showmenu ();
這是一個無參函數,主要實現「功能選擇」的界面,在這個界面里有顯示系統的各項功能選單,根據每個功能前面的序號進行選擇。等執行完每一個函數功能後,按任一鍵回到主界面也要通過這個函數來實現!3、 輸入記錄函數addstudent (stu *s) 這是一個帶參函數,用來執行第學生成績記錄的輸入,當學生為0時停止輸入。
演算法:利用函數參數s,並將s->next設為NULL。每輸入一個數據就聲明一個新節點p,把p->next設為NULL,並且鏈接到之前列表的尾端。4、 顯示記錄函數showstudent (stu *s) 這是一個不返回值的有參函數,形參為「鏈表頭的指針」,負責對全部學生成績記錄的輸出,不足之處就是不能對學生成績進行分頁顯示。 演算法:先將p結點的指針指向第一個結點,將p結點(即第一個結點)的數據輸出。然後再將p結點的指針指向p指針的的指針(即下一結點),將p結點(即第一結點)的數據輸出。重復執行此步聚直到p指針指向NULL為止。5、 查找記錄函數findstudent (stu *s) 這是一個不返回值的有參函數,形參為「鏈表頭的指針」,實現按學號對某個學生進行查找,並顯示所查找到的記錄。 演算法:採用線性查找法往下一個節點查找。輸入所要查找的學生的學號s,設一個指針變數p,先指向第一個結點,當strcmp(p->name,s) && p != NULL時,使p後移一個結點,如果p!=NULL,輸出p所指的結點。6、 刪除記錄函數delstudent (stu *s) 這是一個有參函數,形參為「鏈表頭的指針」,先輸入要刪除的學生記錄的學號,找到後顯示該學生信息,等確認後便可按「Y」進行刪除。 演算法:從p指向的第一個結點開始,檢查該結點中的num值是否等於輸入的要求刪除的那個學號。如果相等就將該結點刪除,如不相等,就將p後移一個結點,再如此進行下去,直到遇到表尾為止。7、保存數據到文件函數savestudent (stu *s) 這是一個不返回值的有參函數,形參為「鏈表頭的指針」,可以把學生記錄保存在電腦上由自己任意命名的二進制文件。8、從文件讀數據函數loadstudent (stu *s) 這是一個不返回值的有參函數,形參為「鏈表頭的指針」,根據輸入的文件地址進行讀取。

三、程序流程圖
1)成績統計:

2)信息錄入:
3)信息修改:
4)信息刪除:
4)信息查詢:

4)信息保存:5)主函數:
四、程序調試及體會
1)程序演示:

2)程序調試:
(1)剛開始沒有那個初始化函數,程序運行後,沒有輸入任何數據就試得去執行顯示功能,結果顯示的是一些亂碼!加入初始化函數後,這種現象也隨之消失。
(2)剛開始執行輸入函數,按學號順序輸入十個學生的成績,輸完後執行顯示功能,學生成績記錄是按學號的反順序顯示的,試著在其中增加一些語句,希望能把學號按正常順序顯示,但暫時沒有成功,所以在輸入成績時只能按學號反順序輸入,最後就按學號正常順序輸出了。
(3)剛開始時,先把成績按平均分排序,再插入一個學生的成績,執行顯示功能,雖然插入的學生的成績能正常插入,但該學生的名次為0。後來,在插入成績之後,調用排序函數,把所有成績重新排序一次。
(4)在輸入函數中設了一個無限循環,可以輸入無數個學生的成績信息,當學號為0的時候則停止輸入。
(5)輸入太多個學生的成績時,屏幕顯示不能控制為一頁一頁顯示,所以為了方便起見,不要輸入太多記錄,十七左右為最佳。
(6)在沒有輸入任何信息的情況下,去執行排序功能,最後顯示有一個記錄,學號、姓名為空白,成績都為0,名次為1。
(7)在輸入選項時不能輸入字母,否則會死循環,建議不要亂輸字母。

3)心得體會:
經過一個星期的課程設計,感覺自己收獲不少!
首先是:鏈表是數據結構的基本體現,所以這個課程設計裡面主要都是用鏈表,而已要達到這樣的功能,使用鏈表相當方便,但不容易理解,所以在這方面我很了很多的時間看課本和參考課外書,使C語言的知識強化了不少。
其次,在做課程設計的過程中,發現了平時很多沒有注意到的問題,例如:返回值函數和不返回值函數兩者在主函數中的調用是不同的…………
更重要的是,這次課程設計雖然花了我不少時間,但正是這些時間,讓我見識到了要學好C語言,數據的處理是相當重要的。這個學生成績管理系統都是在自己知識范圍內完成的,所以界面清晰簡單,可能不是很好看,但絕對實用!
從這里我也得到一個體會,做一個程序,或者開發一個軟體,應該著重從它的後台製作入手,不能做出一個中看不中用的程序或者軟體。
相信這次的課程設計為我以後繼續從事計算機工作打了一個小小的開頭。

參考書目;

[1]譚浩強. C程序設計(第三版) . 北京:清華大學出版社, 2006
[2]譚浩強. C程序設計上機指導(第三版) . 北京:清華大學出版社, 2005
[3]嚴蔚敏、吳偉民. 數據結構(C語言版) . 北京:清華大學出版社, 2006
計算機科學與技術系課程設計評分表

G. 數據結構,用C語言實現,基於鏈表的學生成績管理系統,根據學號和姓名創建索引

看可以不咯?#includeintavgGrade(inta[50]){inti,sum=0,max=0,min=0;doubleavg=0.0;max=a[0];min=a[0];for(i=0;imax)max=a[i];if(a[i]a[i]){temp=a[i];a[i]=a[j];a[j]=temp;}}else{if(a[j]a[i]){for(s=49;s>=i;s--)a[s+1]=a[s];break;}a[i]=n;}intdeleteGrade(inta[50]){intx,i,j;printf("請輸入你要刪除的成績:\n");scanf("%d",&x);for(i=0;i<10;i++){if(a[i]==x)for(j=i+1;j<10;j++)a[i]=a[j];a[j]='\0';}}voidmain(){intn,i,a[50];printf("請輸入50個學生的成績:\n");for(i=0;i<50;i++){scanf("%d",&a[i]);}while(1){printf("--------------------------\n");printf("請選擇您的功能:\n\n");printf("0錄入成績\n");printf("1輸出成績\n");printf("2輸出平均分、最高分、最低分\n");printf("3成績降序或升序排列\n");printf("4插入一個成績\n");printf("5刪除用戶給定的成績\n");printf("6退出\n\n");printf("--------------------------\n");scanf("%d",n);switch(n){case0:printf("請輸入50個學生的成績:\n");for(i=0;i<50;i++){scanf("%d",&a[i]);}break;case1:for(i=0;i<50;i++){printf("%d",a[i]);}break;case2:avgGrade(a);break;case3:compositor(a);break;case4:insertGrade(a);break;case5:deleteGrade(a);break;case6:exit(0);}}return0;}

H. C語言數據結構 編寫【學生成績管理系統】

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <memory.h>
#include <string.h>

#define FILE1 "1.txt"
#define FILE2 "2.txt"
#define FILE3 "3.txt"
#define FILE4 "4.txt"
struct STUDENT
{
char name[20];
int number;
int chinese;
int math;
int english;
int total;
};
typedef STUDENT student;
int count = 0;
student *ss = NULL;

void combine2files()
{
FILE *in, *out;
student s;

out = fopen(FILE3, "w");
in = fopen(FILE1, "r");

if (! || !out)
{
printf("can't open file(s)\n");
exit(-1);
}

while (1)
{
s.name[0] = '\0';
fscanf(in, "%s %d %d %d %d", s.name, &s.number, &s.chinese, &s.math, &s.english);

if (s.name[0] == '\0')
break;

++count;
fprintf(out, "%s %d %d %d %d\n", s.name, s.number, s.chinese, s.math, s.english);
/* printf("%s %d %d %d %d\n", s.name, s.number, s.chinese, s.math, s.english); */
}

fclose(in);
fflush(in);
in = fopen(FILE2, "r");

if (!in)
{
fclose(out);
printf("can't open file\n");
exit(-1);
}

while (1)
{
s.name[0] = '\0';
fscanf(in, "%s %d %d %d %d", s.name, &s.number, &s.chinese, &s.math, &s.english);

if (s.name[0] == '\0')
break;

++count;
fprintf(out, "%s %d %d %d %d\n", s.name, s.number, s.chinese, s.math, s.english);
/* printf("%s %d %d %d %d\n", s.name, s.number, s.chinese, s.math, s.english); */
}

fclose(in);
fclose(out);
}

void check4makeup()
{
FILE *in, *out;
student s;

out = fopen(FILE4, "w");
in = fopen(FILE3, "r");

if (!in || !out)
{
printf("can't open file(s)\n");
exit(-1);
}

while (1)
{
s.name[0] = '\0';
fscanf(in, "%s %d %d %d %d", s.name, &s.number, &s.chinese, &s.math, &s.english);

if (s.name[0] == '\0')
break;

if (s.chinese < 60 || s.math < 60 || s.english < 60)
fprintf(out, "%s %d %d %d %d\n", s.name, s.number, s.chinese, s.math, s.english);
}

fclose(in);
fclose(out);
}

void selectsort(int type = 0)
{
int i, j, k;
student s;

for (i = 0; i < count - 1; ++i)
{
k = i;
for (j = i + 1; j < count; ++j)
{
if (type == 0)
{
if (ss[k].total < ss[j].total)
k = j;
}
else
{
if (strcmp(ss[k].name, ss[j].name) < 0)
k = j;
}
}

if (k != i)
{
memcpy(&s, &ss[i], sizeof(student));
memcpy(&ss[i], &ss[k], sizeof(student));
memcpy(&ss[k], &s, sizeof(student));
}
}
}

void bubblesort()
{
int i, j;
student s;

for (i = 0; i < count - 1; ++i)
{
for (j = count - 1; j > i; --j)
if (ss[j].total > ss[j-1].total)
{
memcpy(&s, &ss[j-1], sizeof(student));
memcpy(&ss[j-1], &ss[j], sizeof(student));
memcpy(&ss[j], &s, sizeof(student));
}
}
}

void outputrecords()
{
int i;
printf("No:\tName:\t\tTotal:\tChinese:\tMath:\tEnglish:\n");

for (i = 0; i < count; ++i)
{
printf("%d\t%s\t\t%d\t%d\t\t%d\t%d\n",
ss[i].number, ss[i].name, ss[i].total, ss[i].chinese, ss[i].math, ss[i].english);
}
}

void sortrecords()
{
int i = 0;
FILE *fp;
char choice;

fp = fopen(FILE3, "r+");

if (!fp)
{
printf("can't open file\n");
exit(-1);
}

while (1)
{
fscanf(fp, "%s %d %d %d %d", ss[i].name, &ss[i].number,
&ss[i].chinese, &ss[i].math, &ss[i].english);

if (i == count)
break;

ss[i].total = ss[i].chinese + ss[i].math + ss[i].english;
++i;
}

rewind(fp);
puts("Please select the sort method:");
puts("1. Bubble Sort");
puts("2. Selection Sort");
choice = getchar();

if (choice == '1')
bubblesort();
else
selectsort();

rewind(fp);
fclose(fp);
}
int binsearch(const char *name)
{
int low = 0;
int high = count - 1;

while (low <= high)
{
int mid = (low + high) / 2;

if (!strcmp(ss[mid].name, name))
{
return mid;
}
else
{
if (strcmp(ss[mid].name, name) > 0)
high = mid - 1;
else
low = mid + 1;
}
}

return -1;
}

int seqsearch(const char *name)
{
int i;

for (i = 0; i < count; ++i)
{
if (!strcmp(ss[i].name, name))
return i;
}
return -1;
}

void findrecord()
{
char nm[20], choice;
int i;

putchar('\n');
selectsort(1);
while (1)
{
printf("Please input the student name you want to find(!=end):\n");
scanf("%s", nm);

if (nm[0] == '!')
break;

puts("Please select the search method:");
puts("1. binary Search");
puts("2. Sequence Search");
choice = getchar();
getchar();

if (choice == '1')
i = binsearch(nm);
else
i = seqsearch(nm);

if (i != -1)
printf("No: %d Name: %s Total: %d Chinese: %d Math: %d English %d\n",
ss[i].number, ss[i].name, ss[i].total, ss[i].chinese, ss[i].math, ss[i].english);
else
printf("Not Found\n");
}
}

void main()
{
combine2files();
ss = (student *)malloc(sizeof(student) * count);
check4makeup();
sortrecords();
outputrecords();
findrecord();
free(ss);
}

I. C語言程序設計課程和數據結構課程的基礎上,完成學生成績管理系統的設計,求源代碼。

#include<iostream.h>
#include<string>
class Score
{
private:
char name[20];
int no;//班級
int term;//學期
int ch,en,ma;//科目成績
int total,average;
public:
Score();
Score(char [],int,int,int,int,int);
~Score();
void menu();
void inputC();//按班級C錄入成績
void inputT();//按學期T錄入成績
void alter();//修改學生成績
int Average();
int Total();
void compute();//計算
void sort();//排序
void find();//查找
void output();//輸出
void fund();//顯示不及格名單
void quit();
};
Score *s[100];
static int i=0;
Score::Score(){}
Score::Score(char na[20],int n,int te,int a,int b,int c)
{
strcpy(name,na);
no=n;
term=te;
ch=a;
en=b;
ma=c;
}
Score::~Score(){}
void Score::menu()
{
int p;
cout<<endl<<"************ 請輸入操作代碼 *************"<<endl;
cout<<"************ 0-------- 按班級錄入成績 *************"<<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;
cin>>p;
switch(p)
{
case 0:inputC();break;
case 1:inputT();break;
case 2:alter();break;
case 3:compute();break;
case 4:sort();break;
case 5:find();break;
case 6:output();break;
case 7:fund();break;
case 8:quit();break;
}
}
void Score::inputC()//按班級C錄入成績
{
cout<<"按班級錄入成績,請輸入以下學生的班級NO:";
cin>>no;
cout<<" 請輸入姓名以輸入x為結束,姓名:";
cin>>name;
while(*name!='x')
{
cout<<" 學期:";cin>>term;
cout<<" 語文:";cin>>ch;
cout<<" 英語:";cin>>en;
cout<<" 數學:";cin>>ma;
s[i]=new Score(name,no,term,ch,en,ma);
cout<<endl<<" 姓名:";cin>>name;
i++;
}
menu();
}
void Score::inputT()//按學期T錄入成績
{
cout<<"按學期錄入成績,請輸入以下學生的成績是第幾學期:";
cin>>term;
cout<<" 請輸入姓名以輸入x為結束,姓名:";
cin>>name;
while(*name!='x')
{
cout<<" 班級:";cin>>no;
cout<<" 語文:";cin>>ch;
cout<<" 英語:";cin>>en;
cout<<" 數學:";cin>>ma;
s[i]=new Score(name,no,term,ch,en,ma);
cout<<endl<<" 姓名:";cin>>name;
i++;
}
menu();
}
void Score::alter()//修改成績
{
cout<<"請輸入您要修改的學生的姓名:";
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{ int n,te,a,b,c;
cout<<" 班級:"<<endl;cin>>n;
cout<<" 學期:";cin>>te;
cout<<" 語文:";cin>>a;
cout<<" 英語:";cin>>b;
cout<<" 數學:";cin>>c;
no=n;
s[h]->term=te;
s[h]->ch=a;
s[h]->en=b;
s[h]->ma=c;
cout<<"數據修改成功!";
break;
}
}
if(h==i) cout<<"對不起!您要修改的學生不存在!"<<endl;
menu();
}
int Score::Total()
{
total=ch+en+ma;
return total;
}
int Score::Average()
{
average=Total()/3;
return average;
}
void Score::compute()
{
for(int h=0;h<i;h++)
cout<<"學生姓名:"<<s[h]->name<<" 班級:"<<s[h]->no<<" 學期:"<<s[h]->term<<" 語文:"<<s[h]->ch<<" 英語:"<<s[h]->en<<" 數學:"<<s[h]->ma<<" 總分:"<<s[h]->Total()<<" 平均分:"<<s[h]->Average()<<endl;
menu();
}
void Score::sort()//排序
{
for(int k=0;k<i;k++)
{
for(int j=k+1;j<i;j++)
{
if(s[k]->Average()<s[j]->Average())
{
Score *t;
t=s[k];s[k]=s[j];s[j]=t;
}
}
}
for(int h=0;h<i;h++)
cout<<"學生姓名:"<<s[h]->name<<" 班級:"<<s[h]->no<<" 學期:"<<s[h]->term<<" 語文:"<<s[h]->ch<<" 英語:"<<s[h]->en<<" 數學:"<<s[h]->ma<<" 總分:"<<s[h]->Total()<<" 平均分:"<<s[h]->Average()<<endl;
menu();
}
void Score::find()//查找
{
cout<<"請輸入您要查找的學生的姓名:";cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
cout<<"學生姓名:"<<s[h]->name<<" 班級:"<<s[h]->no<<" 學期:"<<s[h]->term<<" 語文:"<<s[h]->ch<<" 英語:"<<s[h]->en<<" 數學:"<<s[h]->ma<<endl;
break;
}
}
if(h==i) cout<<"對不起!您要查找的學生不存在!"<<endl;
menu();
}
void Score::fund()
{
cout<<"語文不及格的學生有:";
for(int h=0;h<i;h++)
if(s[h]->ch<60) cout<<s[h]->name;
cout<<"英語不及格的學生有:";
for(h=0;h<i;h++)
if(s[h]->en<60) cout<<s[h]->name;
cout<<"數學不及格的學生有:";
for(h=0;h<i;h++)
if(s[h]->ma<60) cout<<s[h]->name;
menu();
}
void Score::output()//輸出
{
cout<<"本系統所有學生成績如下:"<<endl;
if(i==0)
cout<<"管理系統中沒有錄入數據或者數據已經被刪除!";
else
{ for(int m=0;m<i;m++)
for(int n=m+1;n<i;n++)
{
if(s[m]->no>s[n]->no)
{Score *t;t=s[m];s[m]=s[n];s[n]=t;}
}
for(int h=0;h<i;h++)
cout<<"學生姓名:"<<s[h]->name<<" 班級:"<<s[h]->no<<" 學期:"<<s[h]->term<<" 語文:"<<s[h]->ch<<" 英語:"<<s[h]->en<<" 數學:"<<s[h]->ma<<" 總分:"<<s[h]->Total()<<" 平均分:"<<s[h]->Average()<<endl;
}
menu();
}
void Score::quit(){exit(0);}
void main()
{
Score score1;
score1.menu();
}

J. 學生成績管理系統數據結構

#include<stdio.h>
#include<stdlib.h>
int Shu;
typedef struct student
{
int num;
float mgar,cgar,egar;
float zong,ping;
}stu;

typedef struct node
{
stu xue;
struct node *next;
} LNode,*LinkList;

LinkList InitLinkList()
{
LinkList L;
L=(LinkList)malloc(sizeof(LNode));
L->next=NULL;
return L;
}

LinkList CreateTail() //尾插法,帶頭結點
{
LinkList L;
LNode *s,*r;
int i,x;
float m,c,e;
L=InitLinkList();
r=L;
x=0;
printf("輸入學生信息的個數:");
scanf("%d",&Shu);
printf("學號 數學 語文 英語\n");
while(x<Shu)
{
s=(LNode *)malloc(sizeof(LNode));
scanf("%d",&i);
s->xue.num=i;
scanf("%f",&m);
s->xue.mgar=m;
scanf("%f",&c);
s->xue.cgar=c;
scanf("%f",&e);
s->xue.egar=e;
s->xue.zong=m+c+e;
s->xue.ping=(m+c+e)/3;
s->next=NULL;
r->next=s;
r=s;
x++;
}

return (L);
}
void prn(LinkList L)
{
LNode *p;
p=L->next;
printf("\n學號 數學 語文 英語 平均成績 總成績\n");
while (p!=NULL)
{
printf("%d %0.2f %0.2f %0.2f %0.2f %0.2f\n",p->xue.num,p->xue.mgar,p->xue.cgar,p->xue.egar,p->xue.ping,p->xue.zong);
p=p->next;
}
printf("\n");
}
void prn1(LinkList L)
{
LNode *p;
int x,y;
p=L->next;
printf("請輸入要查詢的學生學號:");
scanf("%d",&x);
while(p)
{
if(x==p->xue.num )
{
y=1;
printf("\n學號 數學 語文 英語 平均成績 總成績\n");
printf("%d %0.2f %0.2f %0.2f %0.2f %0.2f\n",p->xue.num,p->xue.mgar,p->xue.cgar,p->xue.egar,p->xue.ping,p->xue.zong);
}
p=p->next;
}
if(y!=1)
printf("不存在該學生\n");
}
void xs(LinkList L)
{
LNode *p;

p=L->next;
float x,y;
printf("輸入要查詢的數學成績范圍:");
scanf("%f",&x);
scanf("%f",&y);
while(p)
{
if(p->xue.mgar>=x && p->xue.mgar<=y)
{printf("\n學號 數學 語文 英語 平均成績 總成績\n");
printf("%d %0.2f %0.2f %0.2f %0.2f %0.2f\n",p->xue.num,p->xue.mgar,p->xue.cgar,p->xue.egar,p->xue.ping,p->xue.zong);
}
p=p->next;
}
}
void ren(LinkList L)
{
LNode *p;
float m,c,e,j;
int i=0;
m=0;c=0;e=0;j=0;
p=L->next;
while(p)
{
m=m+p->xue.mgar;
c=c+p->xue.cgar;
e=e+p->xue.egar;
j=j+p->xue.ping;
p=p->next;
i++;
}

printf("班級平均成績\n");
printf("數學 語文 英語 總平均成績 總人數\n");
printf("%0.2f %0.2f %0.2f %0.2f %d",m/i,c/i,e/i,j/i,i);
}
void del(LinkList L)
{
int x;
LNode *p,*q;
p=L->next;
q=L;
printf("請輸入要刪除的學生學號:");
scanf("%d",&x);
while(p)
{
if(p->xue.num==x)
{
q->next=p->next;
break;
}
else
{
p=p->next;
q=q->next;
}
}
Shu--;
}
LinkList add(LinkList L)
{
LNode *s;
int n,i,x;
float m,c,e;
i=0;
printf("請輸入要添加的學生信息的人數:");
scanf("%d",&x);
printf("\n學號 數學 語文 英語 \n");
while(i<x)
{
s=(LinkList)malloc(sizeof(LNode));
scanf("%d",&n);
s->xue.num=n;
scanf("%f",&m);
s->xue.mgar=m;
scanf("%f",&c);
s->xue.cgar=c;
scanf("%f",&e);
s->xue.egar=e;
s->xue.zong=m+c+e;
s->xue.ping=(m+c+e)/3;
s->next=L->next;
L->next=s;
i++;
Shu++;
}
return L;
}
LinkList pxm(LinkList L)
{
printf("按數學成績排名:");
int i;
LNode *p,*q,*a;

for(i=0;i<Shu;i++)
{
p=L->next;
q=p->next;
while(q)
{
if(p->xue.mgar<=q->xue.mgar)
{
p->next=q->next;
q->next=L->next;
L->next=q;
a=p;
p=q;
q=a;
}
p=p->next;
q=q->next;
}
}
prn(L);
}
void cd()
{
printf("\t\t\t1、輸入學生信息\n");
printf("\t\t\t2、查詢學生學號信息\n");
printf("\t\t\t3、查詢學生成績信息\n");
printf("\t\t\t4、班級平均成績及人數\n");
printf("\t\t\t5、刪除學生成績\n");
printf("\t\t\t6、增加學生成績\n");
printf("\t\t\t7、學生信息排序\n"); //按數學成績排名
printf("\t請先進行操作1,按數字8可顯示全部信息,再進行其他操作\n");
printf("請輸入選項:");
}
int main()
{
int i;
LinkList L;
do
{
cd();
scanf("%d",&i);
switch(i)
{
case 1:
{
system("cls");
L=CreateTail();
prn(L);break;}
case 2:
{
system("cls");
prn1(L);
break;
}
case 3:
{
system("cls");
xs(L);break;
}
case 4:
{
system("cls");
ren(L);break;
}
case 5:
{
system("cls");
del(L);break;
}
case 6:
{
system("cls");
add(L);
prn(L); break;
}
case 7:
{
system("cls");
pxm(L); break;
}
case 8:
{
prn(L);break;
}
}}while(i<=8 && i>=1);
}
希望對你能有所幫助。

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919