满意答案
dgfetc583
2013.12.10
采纳率:47% 等级:12
已帮助:14710人
class student
{
public:
char m_strName[10]; // 姓名
int m_nNum; // 学号
float m_dScore[4]; // 成绩
};
void InputScore(student* p, int nNumber)
{
if(nNumber > 10)
{
printf("学生已超过10名!\n");
return;
}
printf("请输入学生学号:");
scanf("%d",&(p[nNumber].m_nNum));
printf("请输入学生姓名:");
scanf("%s",&(p[nNumber].m_strName));
printf("请输入数学成绩:");
scanf("%f",p[nNumber].m_dScore);
printf("请输入语文成绩:");
scanf("%f",p[nNumber].m_dScore+1);
printf("请输入英语成绩:");
scanf("%f",p[nNumber].m_dScore+2);
printf("请输入计算机成绩:");
scanf("%f",p[nNumber].m_dScore+3);
}
void OutputScore(student* p, int nNumber)
{
for(int i=0; i
{
printf("\n学号:%d\n",p[i].m_nNum);
printf("姓名:%s\n",p[i].m_strName);
printf("数学成绩:%.2f\n",p[i].m_dScore[0]);
printf("语文成绩:%.2f\n",p[i].m_dScore[1]);
printf("英语成绩:%.2f\n",p[i].m_dScore[2]);
printf("计算机成绩:%.2f\n",p[i].m_dScore[3]);
}
}
void MondifyScore(student *p, int nNumber)
{
int nChoice;
printf("请输入要修改的学生的学号:\n");
scanf("%d",&nChoice);
int i;
for(i=0; i
if(p[i].m_nNum == nChoice) break;
if(i == nNumber)
{
printf("未找到该学号学生\n");
return;
}
printf("请修改学生学号:");
scanf("%d",&(p[i].m_nNum));
printf("请修改学生姓名:");
scanf("%s",&(p[i].m_strName));
printf("请修改数学成绩:");
scanf("%f",p[i].m_dScore);
printf("请修改语文成绩:");
scanf("%f",p[i].m_dScore+1);
printf("请修改英语成绩:");
scanf("%f",p[i].m_dScore+2);
printf("请修改计算机成绩:");
scanf("%f",p[i].m_dScore+3);
}
void main()
{
student ar[10];
int nChoice;
int nStudentNumber = 0; // 现有的学生数量
do
{
printf("\n***************欢迎使用班级管理系统,请输入选项:****************\n");
printf("1.成绩录入\n");
printf("2.成绩显示\n");
printf("3.成绩保存\n");
printf("4.成绩修改\n");
printf("5.退出系统\n");
scanf("%d",&nChoice);
switch(nChoice)
{
case 1:InputScore(ar, nStudentNumber);
nStudentNumber++;
break;
case 2:OutputScore(ar, nStudentNumber);
break;
case 3:
break;
case 4:MondifyScore(ar, nStudentNumber);
break;
}
}while(nChoice != 5);
}
差不多了,成绩保存的没有做,不清楚你怎么保存。剩下一点自己改改吧
10分享举报