帮忙修改一下这个c++程序

来源:百度知道 编辑:UC知道 时间:2024/06/07 22:52:31
如下是学生管理系统的程序,输入输出的部分不符合老师要求,老师要求的是运行程序,选择1能在磁盘上建立一个文本文档,输入学生信息,将输入的学生资料保存到那个刚建立的磁盘文本文档里,然后选择2将此文档里学生的信息显示出来,最重要的是,关闭程序,下次重新运行该程序时,选择2还能显示上次输入的学生信息。希望哪位高手能帮我改一下~~改好了还可以加分哦~~
#include<iostream.h>
#include<string.h>
#include<iomanip.h>
#include<conio.h>
#include<iostream>
struct student
{
char name[8];
int num;
int GS,YY,JSJ,SUM;
};

int s=0;
class student1
{
private:
student stu[40];
char name;
int num;
int GS,YY,JSJ,SUM;

public:
void sr(char *,int,char *,int,int,int);
void print(int);
int jc(int xxh)
{
int m=0;
while(m<=s+1)
if(xxh==stu[m++].num)
break;
if(m>s+1)
return 0;
else
return 1;
}
void cz(int);
void sc(int);
void sum(int);
};

void student1::sr(char *xm,int xh,char *dz,int gs,int yy,int jsj)
{

你这个程序好牛B啊!
帮你适当改写了一下,顺便加了保存/读取学生信息的功能:
#include<iostream.h>
#include<string.h>
#include<iomanip.h>
#include<conio.h>
#include<stdio.h>

typedef struct _StudentInfo
{
char name[8];
int no;
int score[3];
} StudentInfo;

StudentInfo stu[40];
int num = 0;

int isNoExist(int no)
{
for (int i = 0; i < num; i++)
{
if (stu->no == no)
{
return 1;
}
}

return 0;
}

void printStudentInfo(int idx)
{
cout<<idx<<"\t";
cout<<stu[idx].name<<"\t";
cout<<stu[idx].no<<"\t";
cout<<stu[idx].score[0]<<"\t";
cout<<stu[idx].score[1]<<"\t";
cout<<stu[idx].score[2]<<"\t";
cout<<endl;
}