C語(yǔ)言學(xué)生成績(jī)管理系統(tǒng)如何開發(fā)
有很多人C語(yǔ)言學(xué)生成績(jī)管理系統(tǒng)不會(huì)開發(fā),該怎么辦呢,下面是學(xué)習(xí)啦小編收集整理的C語(yǔ)言學(xué)生成績(jī)管理系統(tǒng)如何開發(fā),希望對(duì)大家有幫助~~
C語(yǔ)言學(xué)生成績(jī)管理系統(tǒng)開發(fā)的方法
1. 用戶對(duì)系統(tǒng)數(shù)據(jù)的輸入。
2. 系統(tǒng)計(jì)算所對(duì)應(yīng)的每門課程的總分和平均分。
3. 對(duì)于相對(duì)應(yīng)學(xué)生的數(shù)據(jù)處理。
4. 排序功能
a.總分高到低以及總分從低到高
b.學(xué)號(hào)由大到小
c.姓名字典順序
5.查詢功能
a.學(xué)號(hào)查詢
b.姓名查詢
6.分析數(shù)據(jù)
7.輸出學(xué)生對(duì)應(yīng)的所有數(shù)據(jù)。
8.數(shù)據(jù)存入文件的寫入與讀取
【設(shè)計(jì)思路】
通過(guò)switch case語(yǔ)句實(shí)現(xiàn)用戶菜單操作,在菜單中通過(guò)用戶的選擇調(diào)用相關(guān)的函數(shù)來(lái)完成用戶的一系列操作以及應(yīng)用。
【模塊圖】
程序總流程圖
【算法步驟】
菜單:
for(i=0;i<66;i++)
printf("*");
printf("\n");
printf("1.Input record\n");
printf("2.Caculate totel and average score of every course\n");
printf("3.Caculate totel and average score of every student\n");
printf("4.Sort in descending order by total score of every student\n");
printf("5.Sort in ascending order by total score of every student\n");
printf("6.Sort in ascending order by number\n");
printf("7.Sort in ascending order by name\n");
printf("8.Search by number\n");
printf("9.Search by name\n");
printf("10.Statistic analysis for every course\n");
printf("11.List record\n");
printf("12.Write to a file\n");
printf("13.Read from a file\n");
printf("0.Exit\n");
for(i=0;i<66;i++)
printf("*");
printf("\n");
printf("Please enter your choice:");
printf("\n");
輸入函數(shù):
void Readscore (STU stu[],int n,int m) //1.輸入數(shù)據(jù)
{
int i,j;
for(i=0;i
{
printf("Input student's ID ,name and score");
scanf("%ld",&stu[i].studentID);
scanf("%s",stu[i].studentName);
for(j=0;j
scanf("%d",&stu[i].score[j]);
}
}
數(shù)據(jù)處理函數(shù):
void Tota (STU stu[],int n,int m) //2.計(jì)算每門課程的總分和平均分
{
int i,j,sum[M];
double ave[M];
for(j=0;j
{
sum[j]=0;
for(i=0;i
{
sum[j]=sum[j]+stu[i].score[j];
}
ave[j]=(double)sum[j]/n;
}
for(i=0;i
printf("Project %d 總分=%d,課程的平均分=%f\n",i+1,sum[i],ave[i]);
}
void Datasort_1 (STU stu[],int n,int m) //3.計(jì)算每個(gè)學(xué)生的總分和平均分
{
int i,j,sum[N];
double ave[N];
for(i=0;i
{
sum[i]=0;
for(j=0;j
{
sum[i]=sum[i]+stu[i].score[j];
}
ave[i]=(double)sum[i]/m;
}
for(i=0;i
printf("ID:%10ld,Name: %s Allscore=%d,The ave=%f\n",stu[i].studentID,stu[i].studentName,sum[i],ave[i]);
}
排序函數(shù):
void Datasort_2 (STU stu[],int n,int m) //4.按每個(gè)學(xué)生的總分由高到低排出名次表
{
int i,j,k,h,sum[N];
STU t;
for(i=0;i
{
sum[i]=0;
for(j=0;j
{
sum[i]=sum[i]+stu[i].score[j];
}
}
for(i=0;i
{
k=i;
for(j=i+1;j
{
if (sum[j]>sum[k])
k=j;
}
if(i!=k)
{
t=stu[i],h=sum[i];
stu[i]=stu[k],sum[i]=sum[k];
stu[k]=t,sum[k]=h;
}
}
for(i=0;i
printf("ID:%10ld,Name:%s,Score:%d\n",stu[i].studentID,stu[i].studentName,sum[i]);
}
void Datasort_3 (STU stu[],int n,int m) //5.按每個(gè)學(xué)生的總分由低到高排出名次表
{
int i,j,k,h,sum[N];
STU t;
for(i=0;i
{
sum[i]=0;
for(j=0;j
{
sum[i]=sum[i]+stu[i].score[j];
}
}
for(i=0;i
{
k=i;
for(j=i+1;j
{
if (sum[j]
k=j;
}
if(i!=k)
{
t=stu[i],h=sum[i];
stu[i]=stu[k],sum[i]=sum[k];
stu[k]=t,sum[k]=h;
}
}
for(i=0;i
printf("ID:%10ld,Name:%s,score:%d\n",stu[i].studentID,stu[i].studentName,sum[i]);
}
void Datasort_4 (STU stu[],int n,int m) //6.按學(xué)號(hào)由小到大排出名次表
{
int i,j,k;
STU t;
for(i=0;i
{
k=i;
for(j=i+1;j
{
if (stu[j].studentID
k=j;
}
if(i!=k)
t=stu[k],stu[k]=stu[i],stu[i]=t;
}
for(i=0;i
{
printf("ID:%10ld,Name:%s\n",stu[i].studentID,stu[i].studentName);
for(j=0;j
printf("Project %d Score:%d\n",j+1,stu[i].score[j]);
}
}
數(shù)據(jù)分析函數(shù):
void Statistis (STU stu[],int n,int m) //10.
{
int i,j,count_1,count_2,count_3,count_4,count_5;
for(j=0;j
{
count_1=0,count_2=0,count_3=0,count_4=0,count_5=0;
for(i=0;i
{
if(stu[i].score[j]>=90)
count_1++;
else if(stu[i].score[j]>=80)
count_2++;
else if(stu[i].score[j]>=70)
count_3++;
else if(stu[i].score[j]>=60)
count_4++;
else
count_5++;
}
printf("project %d\n",j+1);
printf("優(yōu)秀:%d\t優(yōu)秀率:%f%\n",count_1,(float)count_1/n);
printf("良好:%d\t良好率:%f%\n",count_2,(float)count_2/n);
printf("中等:%d\t中等率:%f\n",count_3,(float)count_3/n);
printf("及格:%d\t及格率:%f\n",count_4,(float)count_4/n);
printf("不及格:%d\t不及格率:%f\n",count_5,(float)count_5/n);
}
}
數(shù)據(jù)界面打印函數(shù):
void List (STU stu[],int n,int m) //11.
{
int i,j,sum[N];
double ave[N];
for(i=0;i
{
sum[i]=0;
for(j=0;j
{
sum[i]=sum[i]+stu[i].score[j];
}
ave[i]=(double)sum[i]/m;
}
for(i=0;i
{
printf("ID:%10ld,Name:%s\n",stu[i].studentID,stu[i].studentName);
for(j=0;j
{
printf("Score %d :%d\n",j+1,stu[i].score[j]);
}
printf("Allscore=%d\n平均分%f\n",sum[i],ave[i]);
}
}
文件處理函數(shù):
void WritetoFile(STU stu[],int n,int m) //將每個(gè)學(xué)生的記錄信息寫入文件
{
Tota(stu,n,m);
Datasort_2 (stu,n,m);
FILE *fp;
if((fp=fopen("student.txt","w"))==NULL)
{
printf("Failure to open student.txt!\n");
exit(0);
}
fwrite(stu,sizeof(STU),n,fp);
fclose(fp);
}
int ReadfromFile(STU stu[],int n,int m)//從文件中讀出每個(gè)學(xué)生的記錄信息并顯示
{
FILE *fp;
int i;
if((fp=fopen("student.txt","r"))==NULL)
{
printf("Failure to open student.txt!\n");
exit(0);
}
for(i=0;!feof(fp);i++)
{
fread(&stu[i],sizeof(STU),1,fp);
}
fclose(fp);
printf("Total student is %d.\n",i-1);
n=i-1;
List(stu,n,m); //輸出從文件中讀出的信息到屏幕上
return i-1;
}
C語(yǔ)言學(xué)生成績(jī)管理系統(tǒng)如何開發(fā)相關(guān)文章:
1.學(xué)生成績(jī)管理系統(tǒng)設(shè)計(jì)論文