學生成績管理系統容易出現的問題和解決方法
發布時間: 2020-12-22 02:38:30
A. C語言編簡單的學生成績管理系統有個bug,輸入成績的時候最後一個數學成績老是顯示4198786不能賦值進去
//姓名,學號,英語,語文,數學三種成績
#include<stdio.h>
#include<stdlib.h>
#definemaxnumber30
intstudent_number;
intcount1=0,count2=0,Operate1=3;
FILE*stream;
typedefstructstu{
intidnumber;
charname[20];
doubleEnglish_score;
doublechinese_score;
doublemath_score;
}Student;
//按學號排序
voidputout_one(Student*sp)
{
for(intj=0;j<10;j++)
printf("******");
printf(" ");
printf("%d%s%.1f%.1f%.1f ",(*sp).idnumber,(*sp).name,(*sp).English_score,(*sp).chinese_score,(*sp).math_score);
for(j=0;j<10;j++)
printf("******");
printf(" ");
}
voidputout_lot(Student*student)
{
for(inti=0;i<=Operate1;i++)
{
for(intj=0;j<10;j++)
printf("******");
printf(" ");
printf("%d%s%.1f%.1f%.1f ",student[i].idnumber,student[i].name,student[i].English_score,student[i].chinese_score,student[i].math_score);
}
for(intj=0;j<10;j++)
printf("******");
printf(" ");
}
voidinput_student(Student*S)//輸入插入學生的信息
{
//printf("請輸入第%d位學生(學號,名字,語文,英語,數學) ",i+1);
scanf("%d",&(*S).idnumber);
scanf("%s",&(*S).name);
scanf("%lf%lf%lf",&(*S).chinese_score,&(*S).English_score,&(*S).math_score);
}
voidid_find_in(Student*S,Student*q)//把新的學生信息加入表單
{
Student*p=S,*t;
while(count1<Operate1+1)
{
t=p;
p++;
count1++;
}
*t=*q;
count1=0;
Operate1++;
}
voidinsert_element(Student*S)//插入學生信息
{
printf("請輸入1位學生(學號,名字,語文,英語,數學) ");
Student*temp=(Student*)malloc(sizeof(Student)),*q=S;
input_student(temp);
id_find_in(S,temp);
}
voiddelet_element(Student*S,intid_n)
{
Student*p=S,*t;
while(count1<Operate1)
{
if((*p).idnumber==id_n)
{
t=p;
printf("已刪除%d號學生信息 ",(*p).idnumber);
while(count2<Operate1-count1-1)
{
*(t-1)=*(++t);
count2++;
}
break;
}
count1++;
p++;
}
count1=0;
count2=0;
Operate1--;
}
intjunge(char*a,char*b)
{
char*p=a,*q=b;
while(*p!='