c语言 添加学生成绩,C语言的问题学生成绩管理程序1添加:在文件末添加学生记录( 爱问知识人...

#include

#include

#include

#include

#include

#include

using namespace std;

void Sort();

void Output();

char stu_no[6];

struct STUDENT

{

char class_no[20];

char student_no[6];

char name[8];

float cpp_prog;

float media;

float english;

float math;

float ave_score;

int order;

bool operator stu;

int size;

bool COMPARE(const STUDENT& x)

{

int flag;

flag = strcmp(x。

student_no, stu_no);

if (flag == 0)

{

return true;

}

else

{

return false;

}

}

void Input(void)

{

int num;

STUDENT temp;

cout > num;

size = num;

for (int i=0; i> temp。

class_no >> temp。student_no >> temp。name

>> temp。cpp_prog >> temp。media >> temp。english

>> temp。math;

stu。push_front(temp); //从前端添加元素

}

}

void Statistic(void)

{

int i;

i=0;

list::iterator p;

for (p=stu。

begin(); p!=stu。end(); p++)

{

(*p)。ave_score = ((*p)。cpp_prog + (*p)。english

+ (*p)。math + (*p)。media) / 4;

}

for (p=stu。

begin(); p!=stu。end(); p++)

{

cout >stu_no;

cout::const_iterator iter;

iter = find_if(stu。begin(),stu。end(),COMPARE);

if(iter == stu。

end() )

cout >stu_no;

STUDENT temp;

list::iterator p;

p = find_if(stu。begin(),stu。end(),COMPARE);

if(p == stu。

end() )

cout > temp。cpp_prog;

cout > temp。media;

cout > temp。english;

cout > temp。math;

(temp)。ave_score = ((temp)。

cpp_prog + (temp)。english

+ (temp)。math + (temp)。media) / 4;

replace_if(stu。begin(),stu。end(),COMPARE,temp);

Sort ();

}

}

void Delete(void)

{

cout >stu_no;

list::iterator p;

p = find_if(stu。

begin(), stu。end(), COMPARE);

stu。erase(p);

Sort();

Output();

}

void Sort(void)

{

int i;

i = 1;

stu。sort();

list::iterator p;

for (p=stu。

begin(); p!=stu。end(); p++)

{

(*p)。order = i;

i++;

}

Output();

}

void Insert(void)

{

STUDENT temp;

cout > temp。

class_no >> temp。student_no >> temp。name

>> temp。cpp_prog >> temp。media >> temp。english

>> temp。math;

temp。ave_score = (temp。

cpp_prog + temp。english +temp。math + temp。media )/4;

stu。push_front(temp);

Sort();

}void Output()

{

list::iterator p ;

int i;

i = 0;

for(p=stu。

begin(); p!=stu。end(); p++)

{

cout > flag;

cin。

ignore();

switch(flag)

{

case '1': Input(); break;

case '2': Output(); break;

case '3': Statistic(); break;

case '4': Sort(); break;

case '5': Lookup(); break;

case '6': Modify(); break;

case '7': Delete(); break;

case '8': Insert(); break;

case '0': exit(0);

}

cout << "*********************************************** " << endl;

cout << endl << endl;

}

return 0;

}

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值