學生成績查詢的設計
1. 學生成績單的管理與設計
這個必須自己做。。。必須的。。。
2. 資料庫設計問題(學生成績查詢系統)
一個表就可以了吧?2個主鍵
3. 如何設計一個學生成績管理系統
這個我以前做過的,
登陸界面要分2種情況,第一個是管理員登陸
第二個是學生登陸,要設定許可權
管理員可以對學生進行管理,可以對學生的成績進行增刪改查的管理。
也可以對學生的信息進行操作,可以增加科目,可以注冊學生,可以編輯學生所在的班級,以及班主任姓名。
學生界面的話,這個許可權就很少了,可以查詢自己的各科成績。你可以把這個查詢做的豐富一點。比如按科目查詢,可以做模糊查詢。可以查詢本次考試的最高分等等。
因為這個系統比較簡單,所以沒什麼好說的,
資料庫我用的是sqlserver,表結構你可以自己想想啊,全說明了就沒意思了。
希望對你能有幫助
4. access中,基於學生成績表,根據用戶輸入的姓氏查詢學生各科成績,用查詢設計怎麼做
SELECT學生成績.*
FROM學生成績
WHERE(((學生成績.姓名)Like[請輸入學生姓氏]&"*"));
查詢設計視圖
5. 簡單的學生成績管理系統的設計
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int shoudsave=0; /* */
struct student
{
char num[10];/* 學號 */
char name[20];
char sex[10];
int cgrade;
int mgrade;
int egrade;
int totle;
int ave;
char neartime[10];/* 最近更新時間 */
};
typedef struct node
{
struct student data;
struct node *next;
}Node,*Link;
void menu()
{
printf("********************************************************************************");
printf("\t1登記學生資料\t\t\t\t\t2刪除學生資料\n");
printf("\t3查詢學生資料\t\t\t\t\t4修改學生資料\n");
printf("\t5保存學生資料\t\t\t\t\t0退出系統\n");
printf("********************************************************************************\n");
}
void printstart()
{
printf("-----------------------------------------------------------------------\n");
}
void Wrong()
{
printf("\n=====>提示:輸入錯誤!\n");
}
void Nofind()
{
printf("\n=====>提示:沒有找到該學生!\n");
}
void printc() /* 本函數用於輸出中文 */
{
printf(" 學號\t 姓名 性別 英語成績 數學成績 C語言成績 總分 平均分\n");
}
void printe(Node *p)/* 本函數用於輸出英文 */
{
printf("%-12s%s\t%s\t%d\t%d\t%d\t %d\t %d\n",p->data.num,p->data.name,p->data.sex,p->data.egrade,p->data.mgrade,p->data.cgrade,p->data.totle,p->data.ave);
}
Node* Locate(Link l,char findmess[],char nameornum[]) /* 該函數用於定位連表中符合要求的接點,並返回該指針 */
{
Node *r;
if(strcmp(nameornum,"num")==0) /* 按學號查詢 */
{
r=l->next;
while(r!=NULL)
{
if(strcmp(r->data.num,findmess)==0)
return r;
r=r->next;
}
}
else if(strcmp(nameornum,"name")==0) /* 按姓名查詢 */
{
r=l->next;
while(r!=NULL)
{
if(strcmp(r->data.name,findmess)==0)
return r;
r=r->next;
}
}
return 0;
}
void Add(Link l) /* 增加學生 */
{
Node *p,*r,*s;
char num[10];
r=l;
s=l->next;
while(r->next!=NULL)
r=r->next; /* 將指針置於最末尾 */
while(1)
{
printf("請你輸入學號(以'0'返回上一級菜單:)");
scanf("%s",num);
if(strcmp(num,"0")==0)
break;
while(s)
{
if(strcmp(s->data.num,num)==0)
{
printf("=====>提示:學號為'%s'的學生已經存在,若要修改請你選擇'4 修改'!\n",num);
printstart();
printc();
printe(s);
printstart();
printf("\n");
return;
}
s=s->next;
}
p=(Node *)malloc(sizeof(Node));
strcpy(p->data.num,num);
printf("請你輸入姓名:");
scanf("%s",p->data.name);
getchar();
printf("請你輸入性別:");
scanf("%s",p->data.sex);
getchar();
printf("請你輸入c語言成績:");
scanf("%d",&p->data.cgrade);
getchar();
printf("請你輸入數學成績:");
scanf("%d",&p->data.mgrade);
getchar();
printf("請你輸入英語成績:");
scanf("%d",&p->data.egrade);
getchar();
p->data.totle=p->data.egrade+p->data.cgrade+p->data.mgrade;
p->data.ave=p->data.totle / 3;
/* 信息輸入已經完成 */
p->next=NULL;
r->next=p;
r=p;
shoudsave=1;
}
}
void Qur(Link l) /* 查詢學生 */
{
int sel;
char findmess[20];
Node *p;
if(!l->next)
{
printf("\n=====>提示:沒有資料可以查詢!\n");
return;
}
printf("\n=====>1按學號查找\n=====>2按姓名查找\n");
scanf("%d",&sel);
if(sel==1)/* 學號 */
{
printf("請你輸入要查找的學號:");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
printf("\t\t\t\t查找結果\n");
printstart();
printc();
printe(p);
printstart();
}
else
Nofind();
}
else if(sel==2) /* 姓名 */
{
printf("請你輸入要查找的姓名:");
scanf("%s",findmess);
p=Locate(l,findmess,"name");
if(p)
{
printf("\t\t\t\t查找結果\n");
printstart();
printc();
printe(p);
printstart();
}
else
Nofind();
}
else
Wrong();
}
void Del(Link l) /* 刪除 */
{
int sel;
Node *p,*r;
char findmess[20];
if(!l->next)
{
printf("\n=====>提示:沒有資料可以刪除!\n");
return;
}
printf("\n=====>1按學號刪除\n=====>2按姓名刪除\n");
scanf("%d",&sel);
if(sel==1)
{
printf("請你輸入要刪除的學號:");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
r=l;
while(r->next!=p)
r=r->next;
r->next=p->next;
free(p);
printf("\n=====>提示:該學生已經成功刪除!\n");
shoudsave=1;
}
else
Nofind();
}
else if(sel==2)
{
printf("請你輸入要刪除的姓名:");
scanf("%s",findmess);
p=Locate(l,findmess,"name");
if(p)
{
r=l;
while(r->next!=p)
r=r->next;
r->next=p->next;
free(p);
printf("\n=====>提示:該學生已經成功刪除!\n");
shoudsave=1;
}
else
Nofind();
}
else
Wrong();
}
void Modify(Link l)
{
Node *p;
char findmess[20];
if(!l->next)
{
printf("\n=====>提示:沒有資料可以修改!\n");
return;
}
printf("請你輸入要修改的學生學號:");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
printf("請你輸入新學號(原來是%s):",p->data.num);
scanf("%s",p->data.num);
printf("請你輸入新姓名(原來是%s):",p->data.name);
scanf("%s",p->data.name);
getchar();
printf("請你輸入新性別(原來是%s):",p->data.sex);
scanf("%s",p->data.sex);
printf("請你輸入新的c語言成績(原來是%d分):",p->data.cgrade);
scanf("%d",&p->data.cgrade);
getchar();
printf("請你輸入新的數學成績(原來是%d分):",p->data.mgrade);
scanf("%d",&p->data.mgrade);
getchar();
printf("請你輸入新的英語成績(原來是%d分):",p->data.egrade);
scanf("%d",&p->data.egrade);
p->data.totle=p->data.egrade+p->data.cgrade+p->data.mgrade;
p->data.ave=p->data.totle/3;
printf("\n=====>提示:資料修改成功!\n");
shoudsave=1;
}
else
Nofind();
}
void Disp(Link l)
{
int count=0;
Node *p;
p=l->next;
if(!p)
{
printf("\n=====>提示:沒有資料可以顯示!\n");
return;
}
printf("\t\t\t\t顯示結果\n");
printstart();
printc();
printf("\n");
while(p)
{
printe(p);
p=p->next;
}
printstart();
printf("\n");
}
void Tongji(Link l)
{
Node *pm,*pe,*pc,*pt,*pa; /* 用於指向分數最高的接點 */
Node *r=l->next;
if(!r)
{
printf("\n=====>提示:沒有資料可以統計!\n");
return ;
}
pm=pe=pc=pt=pa=r;
while(r!=NULL)
{
if(r->data.cgrade>=pc->data.cgrade)
pc=r;
if(r->data.mgrade>=pm->data.mgrade)
pm=r;
if(r->data.egrade>=pe->data.egrade)
pe=r;
if(r->data.totle>=pt->data.totle)
pt=r;
if(r->data.ave>=pa->data.ave)
pa=r;
r=r->next;
}
printf("------------------------------統計結果--------------------------------\n");
printf("總分最高者:\t%s %d分\n",pt->data.name,pt->data.totle);
printf("平均分最高者:\t%s %d分\n",pa->data.name,pa->data.ave);
printf("英語最高者:\t%s %d分\n",pe->data.name,pe->data.egrade);
printf("數學最高者:\t%s %d分\n",pm->data.name,pm->data.mgrade);
printf("c語言最高者:\t%s %d分\n",pc->data.name,pc->data.cgrade);
printstart();
}
void Sort(Link l)
{
Link ll;
Node *p,*rr,*s;
ll=(Link)malloc(sizeof(Node)); /* 用於做新的連表 */
ll->next=NULL;
if(l->next==NULL)
{
printf("\n=====>提示:沒有資料可以排序!\n");
return ;
}
p=l->next;
while(p)
{
s=(Node*)malloc(sizeof(Node)); /* 新建接點用於保存信息 */
s->data=p->data;
s->next=NULL;
rr=ll;
while(rr->next!=NULL && rr->next->data.totle>=p->data.totle)
rr=rr->next;
if(rr->next==NULL)
rr->next=s;
else
{
s->next=rr->next;
rr->next=s;
}
p=p->next;
}
free(l);
l->next=ll->next;
printf("\n=====>提示:排序已經完成!\n");
}
void Save(Link l)
{
FILE* fp;
Node *p;
int flag=1,count=0;
fp=fopen("c:\\student","wb");
if(fp==NULL)
{
printf("\n=====>提示:重新打開文件時發生錯誤!\n");
exit(1);
}
p=l->next;
while(p)
{
if(fwrite(p,sizeof(Node),1,fp)==1)
{
p=p->next;
count++;
}
else
{
flag=0;
break;
}
}
if(flag)
{
printf("\n=====>提示:文件保存成功.(有%d條記錄已經保存.)\n",count);
shoudsave=0;
}
fclose(fp);
}
int main()
{
Link l;/* 連表 */
FILE *fp; /* 文件指針 */
int sel;
char ch;
char jian;
int count=0;
Node *p,*r;
l=(Node*)malloc(sizeof(Node));
l->next=NULL;
r=l;
fp=fopen("C:\\student","rb");
if(fp==NULL)
{
printf("\n=====>提示:文件還不存在,是否創建?(y/n)\n");
scanf("%c",&jian);
if(jian=='y'||jian=='Y')
fp=fopen("C:\\student","wb");
else
exit(0);
}
printf("\n=====>提示:文件已經打開,正在導入記錄......\n");
while(!feof(fp))
{
p=(Node*)malloc(sizeof(Node));
if(fread(p,sizeof(Node),1,fp)) /* 將文件的內容放入接點中 */
{
p->next=NULL;
r->next=p;
r=p; /* 將該接點掛入連中 */
count++;
}
}
fclose(fp); /* 關閉文件 */
printf("\n=====>提示:記錄導入完畢,共導入%d條記錄.\n",count);
while(1)
{
menu();
printf("請你選擇操作:");
scanf("%d",&sel);
if(sel==0)
{
if(shoudsave==1)
{ getchar();
printf("\n=====>提示:資料已經改動,是否將改動保存到文件中(y/n)?\n");
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
Save(l);
}
printf("\n=====>提示:你已經退出系統,再見!\n");
break;
}
switch(sel)
{
case 1:Add(l);break; /* 增加學生 */
case 2:Del(l);break;/* 刪除學生 */
case 3:Qur(l);break;/* 查詢學生 */
case 4:Modify(l);break;/* 修改學生 */
case 5:Save(l);break;/* 保存學生 */
case 9:printf("\t\t\t==========幫助信息==========\n");break;
default: Wrong();getchar();break;
}
}
system("pause");
return 0;
}
6. 數據結構課程設計 學生成績查詢系統
這個是我自己寫的..我也在學習中,不足之處請諒解:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
void newinf(void);
void showinf(void);
void insertinf(void);
void deleteinf(void);
void saveinf(void);
void infoinf(void);
void sortinf(void);
void searchinf(void);
void menu(void);
struct inf{
int number;
char name[80];
int score;
inf * prev,* next;
};
inf * head,* tail;
int high,low,average;
int total=0;
void main(void)
{ system("cls");
system("color 1a");
system("title 成績管理系統");
menu();
int choice;
scanf("%d",&choice);
system("cls");
switch(choice){
case 0:
exit(0);
break;
case 1:
newinf();
main();
break;
case 2:
searchinf();
main();
break;
case 3:
insertinf();
main();
break;
case 4:
deleteinf();
main();
break;
case 5:
sortinf();
main();
break;
case 6:
showinf();
main();
break;
case 7: //數據統計
printf("共有學生%d人\n",total);
system("pause");
main();
break;
case 8: //保存
saveinf();
main();
break;
}
}
void newinf(void)
{
inf * temp;
temp=(inf *)malloc(sizeof(inf));
printf("請輸入學號\n");
scanf("%d",&temp->number);
printf("請輸入姓名\n");
scanf("%s",&temp->name);
printf("請輸入成績\n");
scanf("%d",&temp->score);
temp->next=NULL;
if(head==NULL){
temp->prev=NULL;
head=temp;
tail=temp;
}
else{
tail->next=temp;
temp->prev=tail;
tail=temp;
}
total++;
}
void showinf(void)
{
inf * temp;
temp=head;
if(head==NULL){
printf("數據不存在\n");
system("pause");
main();
}
do{
printf("學號%d 姓名%s 成績%d\n",temp->number,temp->name,temp->score);
temp=temp->next;
}
while(temp!=NULL);
system("pause");
}
void insertinf(void)
{
if(head==NULL){
printf("數據不存在\n無法插入,請選擇 1.增加記錄\n");
system("pause");
main();
}
int input,count=0;
inf * temp,*search,*temp2;
printf("請輸入在第幾條後插入\n");
scanf("%d",&input);
while(input>total||input<=0){
printf("輸入錯誤請重新輸入");
scanf("%d",&input);
};
temp=(inf *)malloc(sizeof(inf));
printf("請輸入學號\n");
scanf("%d",&temp->number);
printf("請輸入姓名\n");
scanf("%s",&temp->name);
printf("請輸入成績\n");
scanf("%d",&temp->score);
search=head;
while(search!=NULL){
count++;
if(input==count){
temp2=search->next;
search->next=temp;
temp->prev=search;
temp->next=temp2;
if(temp2!=NULL){
temp2->prev=temp;
}
}
search=search->next;
};
total++;
}
void deleteinf(void)
{
if(head==NULL){printf("數據不存在!\n");<br> system("pause"); <br> main();}
int input,count=0;
inf * temp,*temp2,*search;
printf("請輸入刪除第幾條\n");
scanf("%d",&input);
while(input>total||input<=0){
printf("輸入錯誤請重新輸入");
scanf("%d",&input);};
search=head;
while(search!=NULL){count++;<br> if(input==count){if(count==1){head=search->next;}
temp=search->prev;
temp2=search->next;
if(temp!=NULL){
temp->next=temp2;}
if(temp2!=NULL){
temp2->prev=temp;}
free(search);}
search=search->next;};
total--;}
void searchinf(void)
{if(head==NULL){<br> printf("數據不存在!\n");<br> system("pause"); <br> main();}
inf * temp;
int choice,number,score;
char name[80];
temp=head;
printf("請選擇查找方式:\n1.按學號查找\n2.按姓名查找\n3.按成績查找\n");
scanf("%d",&choice);
printf("請輸入對應信息\n");
switch(choice){case 1:<br> scanf("%d",&number);<br> while(temp!=NULL){if(temp->number==number){printf("學號%d 姓名%s 成績%d\n",temp->number,temp->name,temp->score);}
temp=temp->next;};
break;
case 2:
getchar();
gets(name);
while(temp!=NULL){if(strcmp(temp->name,name)==0){printf("學號%d 姓名%s 成績%d\n",temp->number,temp->name,temp->score);}
temp=temp->next;};
break;
case 3:
scanf("%d",&score);
while(temp!=NULL){
if(temp->score==score){printf("學號%d 姓名%s 成績%d\n",temp->number,temp->name,temp->score);}
temp=temp->next;};
break;}
system("pause"); }
void sortinf(void)
{inf *temp,*temp2;<br> int number,score;<br> char name[80];<br> temp=head;<br> if(head==NULL){<br> printf("數據不存在\n");<br> system("pause"); <br> main();}
for(int i=1;i<=total*total;i++){
if(temp->next==NULL){temp=head;<br> continue;}
temp2=temp->next;
if(temp->number>temp2->number){
name=temp->name;
score=temp->score;
number=temp->number;
temp->name=temp2->name;
temp->score=temp2->score;
temp->number=temp2->number;
temp2->name=name;
temp2->score=score;
temp2->number=number;}
temp=temp->next;}
printf("排序完成\n");
system("pause"); }
void menu(void)
{
system("cls");
printf(" ********************************************************************\n");
printf(" * *\n");
printf(" * *\n");
printf(" * *\n");
printf(" * 成績管理系統 *\n");
printf(" * *\n");
printf(" * *\n");
printf(" * *\n");
printf(" ********************************************************************\n");
printf("1.增加記錄\n2.查找記錄\n3.插入記錄\n4.刪除記錄\n5.記錄排序\n6.查看記錄\n7.數據統計\n8.保存記錄\n0.退出\n");
}void saveinf(void)
{
printf("請注意,保存信息將覆蓋原文件!\n確認請輸入y:\n");
char a;
getchar();
scanf("%c",&a);
if(a=='y'||a=='Y')
{
FILE *file;
inf *temp;
file=fopen("save.txt","w+");
temp=head;
while(temp!=NULL)
{
fprintf(file,"學號:%d 姓名:%s 成績:%d\n",temp->number,temp->name,temp->score);
temp=temp->next;
}
printf("保存成功!");
system("pause");
main();
}
else
{
main();
}
}
7. 設計一個學生成績管理系統,能對學生成績信息(學號,課程名稱,成績)進行查詢(要求可以使用模糊查詢和
簡單模式,具體功能你自己可以繼續編寫
#include<stdio.h>
#include<string.h>
#include<conio.h>
struct student{
char number[20];
char name[30];
float scor_eng;
float scor_math;
float scor_phy;
};
void printmenu();
int mycreat(int xueshengnumber,struct student record[100]);
void myshow(int xueshengnumber,struct student record[100]);
void myselect(int xueshengnumber,struct student record[100]);
void mymodify(int xueshengnumber,struct student record[100]);
int myadd(int xueshengnumber,struct student record[100]);
int mydelete(int xueshengnumber,struct student record[100]);
void mysort(int xueshengnumber,struct student record[100]);
/* ------------------------------------------------------------------*/
main()
{
char choose,yesorno;
struct student record[100]; //用結構體代替原來的5個數組
int xueshengnumber=0; /*輸入的學生數 */
do
{
printmenu(); /* 列印菜單界面 */
choose=getch();
while(choose>'7'||choose<'0')
{
printf("請在0-7之間選擇\n");
choose=getch();
}
switch(choose)
{
case '1':
{
xueshengnumber=mycreat(xueshengnumber,record);
break;
}
case '2':
{
myshow(xueshengnumber,record);
break;
}
case '3':
{
myselect(xueshengnumber,record);
break;
}
case '4':
{
mymodify(xueshengnumber,record);
break;
}
case '5':
{
xueshengnumber=myadd(xueshengnumber,record);
break;
}
case '6':
{
xueshengnumber=mydelete(xueshengnumber,record);
break;
}
case '7':
{
mysort(xueshengnumber,record);
break;
}
case '0':
{
printf("確實要退出系統嗎?");
break;
}
}
printf("\n要繼續選擇嗎{Y/N}\n");
do
yesorno=getch();
while(yesorno!='Y'&&yesorno!='N'&&yesorno!='y'&&yesorno!='n');
}while(yesorno=='Y'||yesorno=='y');
}
/* ------------------------------------------------------------------*/
void printmenu()
{
printf("|----------------------------------------------------------------------|\n");
printf("| 學生成績管理系統,請選擇數字進行相應操作 |\n");
printf("| 1:錄入學生成績(包括姓名、學號、英語、數學、物理),輸入完成按「結束」|\n");
printf("| 2:顯示學生成績; |\n");
printf("| 3:查詢學生成績; |\n");
printf("| 4:修改學生成績; |\n");
printf("| 5:添加學生成績; |\n");
printf("| 6:刪除學生成績; |\n");
printf("| 7:排序學生成績; |\n");
printf("| 0:退出該成績; |\n");
printf("|----------------------------------------------------------------------|\n");
}
int mycreat(int xueshengnumber,struct student record[100])
{/*----------------------------------------*/
struct student temp;
int x;
printf("請輸入第%d個記錄:\n",xueshengnumber+1);
printf("姓名(用#結束):\n");
do
gets(temp.name);
while(strcmp(temp.name,"")==0);
printf("學號(用#結束):\n");
do
gets(temp.number);
while(strcmp(temp.number,"")==0);
printf("英語成績:\n");
do
{
fflush(stdin);
x=scanf("%f",&temp.scor_eng); /*返回值含義見P38*/
}while(temp.scor_eng>100.0||temp.scor_eng<0.0||x==0);
printf("數學成績:\n");
do
{
fflush(stdin);
x=scanf("%f",&temp.scor_math);
}while(temp.scor_math>100.0||temp.scor_math<0.0||x==0);
printf("物理成績:\n");
do
{
fflush(stdin);
x=scanf("%f",&temp.scor_phy);
}while(temp.scor_phy>100.0||temp.scor_phy<0.0||x==0);
/* 輸入結束控制 */
while(temp.name[0]!='#' && temp.number[0]!='#')
{
/*保存到數組中 */
record[xueshengnumber]=temp;
xueshengnumber++;
/* 重復上次輸入 */
printf("請輸入第%d個記錄:\n",xueshengnumber+1);
printf("姓名(用#結束):\n");
do
gets(temp.name);
while(strcmp(temp.name,"")==0);
printf("學號(用#結束):\n");
do
gets(temp.number);
while(strcmp(temp.number,"")==0);
printf("英語成績:\n");
do
{
fflush(stdin);
x=scanf("%f",&temp.scor_eng); /*返回值含義見P38*/
}while(temp.scor_eng>100.0||temp.scor_eng<0.0||x==0);
printf("數學成績:\n");
do
{
fflush(stdin);
x=scanf("%f",&temp.scor_math);
}while(temp.scor_math>100.0||temp.scor_math<0.0||x==0);
printf("物理成績:\n");
do
{
fflush(stdin);
x=scanf("%f",&temp.scor_phy);
}while(temp.scor_phy>100.0||temp.scor_phy<0.0||x==0);
}
/*----------------------------------------*/
return(xueshengnumber);
}
/* 顯示模塊 */
void myshow(int xueshengnumber,struct student record[100])
{
int i;
if(xueshengnumber==0) printf("請先錄入學生成績,再顯示學生成績\n");
else
{
printf("\n\n\n顯示所有學生成績\n");
printf("姓名 學號 英語成績 數學成績 物理成績\n");
for(i=0;i<xueshengnumber;i++)
{
printf("%-15s",record[i].name);
printf("%-15s",record[i].number);
printf("%-13f",record[i].scor_eng);
printf("%-13f",record[i].scor_math);
printf("%-13f",record[i].scor_phy);
printf("\n");
}
}
}
/* 查詢模塊 */
void myselect(int xueshengnumber,struct student record[100])
{
int i;
char tempnumber[20]="";
printf("\n\n請輸入要查詢的學生學號:");
do
gets(tempnumber);
while(strcmp(tempnumber,"")==0);
for(i=0;i<xueshengnumber;i++)
if(strcmp(tempnumber,record[i].number)==0)
{
printf("查詢結果:\n");
printf("姓名 學號 英語成績 數學成績 物理成績\n");
printf("%-15s",record[i].name);
printf("%-15s",record[i].number);
printf("%-13f",record[i].scor_eng);
printf("%-13f",record[i].scor_math);
printf("%-13f",record[i].scor_phy);
printf("\n");
}
}
void mymodify(int xueshengnumber,struct student record[100])
{
int i;
struct student temp;
printf("請輸入要修改的學生學號\n");
do
gets(temp.number);
while(strcmp(temp.number,"")==0);
for(i=0;i<xueshengnumber;i++)
if(strcmp(temp.number,record[i].number)==0) break; //從此分支出來的i是有此學生的
if(i==xueshengnumber) //表明整個循環走完了也沒找到與tempnumber相等的學號
printf("查詢結果無此學生\n");
else
{
printf("請輸入要修改的學生姓名\n");
do
gets(temp.name);
while(strcmp(temp.name,"")==0);
strcpy(record[i].name,temp.name);
printf("請輸入要修改的英語成績\n");
do
{ fflush(stdin);
scanf("%f",&temp.scor_eng);
}
while(temp.scor_eng>100.0||temp.scor_eng<0.0);
record[i].scor_eng=temp.scor_eng;
printf("請輸入要修改的數學成績\n");
do
{ fflush(stdin);
scanf("%f",&temp.scor_math);
}
while(temp.scor_math>100.0||temp.scor_math<0.0);
record[i].scor_math=temp.scor_math;
printf("請輸入要修改的物理成績\n");
do
{ fflush(stdin);
scanf("%f",&temp.scor_phy);
}
while(temp.scor_phy>100.0||temp.scor_phy<0.0);
record[i].scor_phy=temp.scor_phy;
}
}
int myadd(int xueshengnumber,struct student record[100])
{
int i;
struct student temp;
printf("請輸入要添加的學生學號\n");
do
gets(temp.number);
while(strcmp(temp.number,"")==0);
for(i=0;i<xueshengnumber;i++)
if(strcmp(temp.number,record[i].number)==0)
{printf("該學號已經存在,請重新輸入要添加的學生學號\n");
do
gets(temp.number);
while(strcmp(temp.number,"")==0);
i=-1;
}
strcpy(record[i].number,temp.number);
printf("請輸入要添加的學生姓名\n");
do
gets(temp.name);
while(strcmp(temp.name,"")==0);
strcpy(record[i].name,temp.name);
printf("請輸入要添加的英語成績\n");
do
{ fflush(stdin);
scanf("%f",&temp.scor_eng);
}
while(temp.scor_eng>100.0||temp.scor_eng<0.0);
record[i].scor_eng=temp.scor_eng;
printf("請輸入要添加的數學成績\n");
do
{ fflush(stdin);
scanf("%f",&temp.scor_math);
}
while(temp.scor_math>100.0||temp.scor_math<0.0);
record[i].scor_math=temp.scor_math;
printf("請輸入要添加的物理成績\n");
do
{ fflush(stdin);
scanf("%f",&temp.scor_phy);
}
while(temp.scor_phy>100.0||temp.scor_phy<0.0);
record[i].scor_phy=temp.scor_phy;
xueshengnumber++;
return xueshengnumber;
}
int mydelete(int xueshengnumber,struct student record[100])
{
int i;
struct student temp;
printf("請輸入要刪除的學生學號:");
do
gets(temp.number);
while(strcmp(temp.number,"")==0);
for(i=0;i<xueshengnumber;i++)
if(strcmp(temp.number,record[i].number)==0) break;
if(i<xueshengnumber)
{
if(i+1==xueshengnumber) xueshengnumber--;
else{
for(;i<xueshengnumber-1;i++)
{
record[i]=record[i+1];
}
xueshengnumber--;
}
}
else
printf("查無此學生");
return xueshengnumber;
}
void mysort(int xueshengnumber,struct student record[100])
{ int i,j;
struct student t;
printf("按學號從小到大地排序\n");
for(i=0;i<xueshengnumber-1;i++)
for(j=0;j<xueshengnumber-1-i;j++)
if(strcmp(record[j].number,record[j+1].number)>0)
{
t=record[j];
record[j]=record[j+1];
record[j+1]=t;
}
}
8. 學生成績管理系統設計
我是趙文滔
#include<stdio.h>
#include<string.h>
#define SIZE 2
struct xs
{
int num;
char name[20];
float yingyu;
float shuxue;
float pingjun;
}xuesheng[SIZE+1],*p=xuesheng;
void main()
{
int a,i,j,k=0,m,n,t;
char b[20],c;
do{
printf("請輸入選項:\n1輸入學生成績\n2按姓名查詢學生成績\n3按學號查找學生成績\n4按姓名排序\n5按學號排序\n6按成績排序\n7列印學生成績\n");
scanf("%d",&a);
if(a==1)
{
printf("請輸入學生姓名、學號、英語成績、數學成績\n");
for(i=1;i<=SIZE;i++)
{
scanf("%s %d %f %f",xuesheng[i].name ,&xuesheng[i].num ,&xuesheng[i].yingyu ,&xuesheng[i].shuxue );
xuesheng[i].pingjun =(xuesheng[i].yingyu+xuesheng[i].shuxue)/2;
}
m=0;
}
else {printf("請先輸入數據\n");m=1;}
}while(m==1);
do
{printf("是否進行其他操作?1/0\n");
scanf("%d",&k);
if(k==1)
{
printf("請再次輸入選擇\n");
scanf("%d",&a);
if(a==2)
{
printf("請輸入要查詢的姓名\n");
scanf("%s",b);
for(i=1;i<=SIZE;i++)
{
if(strcmp(b,xuesheng[i].name)==0)printf("姓名:%s學號%d英語成績%f數學成績:%f平均成績%f\n",xuesheng[i].name ,xuesheng[i].num ,xuesheng[i].yingyu ,xuesheng[i].shuxue,xuesheng[i].pingjun );
}
}
if(a==3)
{
printf("請輸入要查詢的學號\n");
scanf("%d",&m);
printf("姓名:%s學號%d英語成績%f數學成績:%f平均成績%f",xuesheng[m-1000].name ,xuesheng[m-1000].num ,xuesheng[m-1000].yingyu ,xuesheng[m-1000].shuxue,xuesheng[m-1000].pingjun );
}
if(a==4)
{
printf("按姓名排序如下:\n");
for(i=1;i<=SIZE;i++)
{ for(j=i+1;j<=SIZE;j++)
if(strcmp(xuesheng[i].name,xuesheng[j].name)>0){*p=xuesheng[j];xuesheng[j]=xuesheng[i];xuesheng[i]=*p;}
}
for(i=1;i<=SIZE;i++)
printf("姓名:%s學號%d英語成績%f數學成績:%f平均成績%f\n",xuesheng[i].name ,xuesheng[i].num ,xuesheng[i].yingyu ,xuesheng[i].shuxue,xuesheng[i].pingjun );
}
if(a==5)
{
printf("按學號排序如下:\n");
for(i=1;i<=SIZE;i++)
for(j=i+1;j<=SIZE;j++)
if(xuesheng[i].num>xuesheng[j].num){*p=xuesheng[j];xuesheng[j]=xuesheng[i];xuesheng[i]=*p;}
for(i=1;i<=SIZE;i++)
printf("姓名:%s學號%d英語成績%f數學成績:%f平均成績%f\n",xuesheng[i].name ,xuesheng[i].num ,xuesheng[i].yingyu ,xuesheng[i].shuxue,xuesheng[i].pingjun );
}
if(a==6)
{
printf("按平均成績排序如下:\n");
for(i=1;i<=SIZE;i++)
for(j=i+1;j<=SIZE;j++)
if(xuesheng[i].pingjun>xuesheng[j].pingjun){*p=xuesheng[j];xuesheng[j]=xuesheng[i];xuesheng[i]=*p;}
for(i=1;i<=SIZE;i++)
printf("姓名:%s學號%d英語成績%f數學成績:%f平均成績%f\n",xuesheng[i].name ,xuesheng[i].num ,xuesheng[i].yingyu ,xuesheng[i].shuxue,xuesheng[i].pingjun );
}
if(a==7)
{
printf("按學號輸出如下:\n");
for(i=1;i<=SIZE;i++)
for(j=i+1;j<=SIZE;j++)
if(xuesheng[i].num>xuesheng[j].num){*p=xuesheng[j];xuesheng[j]=xuesheng[i];xuesheng[i]=*p;}
for(i=1;i<=SIZE;i++)
printf("姓名:%s學號%d英語成績%f數學成績:%f平均成績%f\n",xuesheng[i].name ,xuesheng[i].num ,xuesheng[i].yingyu ,xuesheng[i].shuxue,xuesheng[i].pingjun );
}
if(a==0)printf("謝謝使用\n");
if(a==8||a==9)printf("請重新輸入\n");
}
}while(a!=0);
}