void data_xiugai() //数据修改
{
int pp;
int i,j,k;
data_daoru();
printf("\n\t请输入要修改学生的学号:");
scanf("%d",&pp);
printf("\n");
for(i=0;i<=count;i++){
if(data[i].number==pp) break;
}
if(i>=count) { printf("\n\t没有找到该学生!\n"); return;}
printf("\n\t学号:%.0d 姓名:%s \n\n\t语文:%d 数学:%d 英语:%d 品德成绩:%d 老师评分:%d\n\n",data[i].number,info[i].name,data[i].chinese,data[i].math,data[i].english,data[i].pinde,data[i].teacher);
printf("\n\t是否修改?\t 1.是 \t 2.否 \t ");
while(1){ //询问
scanf("%d",&j);
switch(j){
case 1:{
for(k=0;k<=count;k++){ //重新排名次
if(data[i].avg>data[k].avg) data[k].ksmc=data[k].ksmc-1;
}
printf("\n\t请输入语文成绩:");
scanf("%d",&data[i].chinese);
while( data[i].chinese < 0 || data[i].chinese > 100 )
{ printf("\t对不起你输入的数据不是 1-100 之间,请从新输入真确的数值!\n");
printf("\t请输入老师评分:");
scanf("%d",&data[i].chinese );
}
printf("\t请输入数学成绩:");
scanf("%d",&data[i].math);
while( data[i].math < 0 || data[i].math > 100 )
{ printf("\t对不起你输入的数据不是 1-100 之间,请从新输入真确的数值!\n");
printf("\t请输入数学成绩:");
scanf("%d",&data[i].math);
}
printf("\t请输入英语成绩:");
scanf("%d",&data[i].english);
while( data[i].english < 0 || data[i].english > 100 )
{ printf("\t对不起你输入的数据不是 1-100 之间,请从新输入真确的数值!\n");
printf("\t请输入英语成绩:");
scanf("%d",&data[i].english);
}
printf("\n\t请输入同学互评成绩:");
scanf("%d",&data[i].huping );
while( data[i].huping < 0 || data[i].huping > 100 )
{ printf("\t对不起你输入的数据不是 1-100 之间,请从新输入真确的数值!\n");
printf("\t请输入同学互评成绩:");
scanf("%d",&data[i].huping );
}
printf("\n\t请输入品德成绩:");
scanf("%d",&data[i].pinde);
while( data[i].pinde < 0 || data[i].pinde > 100 )
{ printf("\t对不起你输入的数据不是 1-100 之间,请从新输入真确的数值!\n");
printf("\t请输入品德成绩:");
scanf("%d",&data[i].pinde);
}
printf("\t请输入老师评分:");
scanf("%d",&data[i].teacher);
while( data[i].teacher < 0 || data[i].teacher > 100 )
{ printf("\t对不起你输入的数据不是 1-100 之间,请从新输入真确的数值!\n");
printf("\t请输入老师评分:");
scanf("%d",&data[i].teacher);
}
data[i].avg=(data[i].chinese+data[i].math+data[i].english)/3.0;
data[i].ceping=(data[i].avg*0.6+data[i].huping *0.1+ data[i].pinde*0.1+data[i].teacher*0.2);
data[i].ksmc=count;
for(k=0;k<count;k++){ //重新排名次
if(data[i].avg>data[k].avg){
data[k].ksmc=data[k].ksmc+1;
if(data[i].ksmc>data[k].ksmc-1)
data[i].ksmc=data[k].ksmc-1;
}
}
printf("\n\t修改成功!\n\n"); data_xieru(); return; //写入文件
}
case 2: return;
default : printf("输入错误!请重新输入!");break;
}
break;
}
printf("\n\n\t\t");
system("pause");
}