| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 978 人关注过本帖
标题:[求助]懂VC的进来看下
只看楼主 加入收藏
long_557799
Rank: 1
等 级:新手上路
威 望:1
帖 子:284
专家分:0
注 册:2007-5-29
收藏
 问题点数:0 回复次数:12 
[求助]懂VC的进来看下

学生成绩统计管理
基本功能:
成绩的输入(学号、姓名、英语、数学、C++语言…);
成绩统计(各科平均成绩、各科成绩“优秀”、“良好”、“中等”、“及格”、“不及格”的人数及其所占比例);
总成绩统计(学生的总成绩、平均成绩及成绩排名)
成绩的统计结果显示,其格式参见题目一。
扩展功能:
学生数据的添加、修改、与删除
学生数据的读取与存储
下面程序是我在网上下载的
但是由于自己乱改了些
所以总成绩的统计(即hi(int i)和lo(int i)函数实现不了功能
希望有高手帮我看下程序
并提出你们的修改意见
小弟在这谢了



#ifndef Score //防止文件重复包含,还能让代码适应多种环境
#define Score
#include<iostream.h>
#include<string.h>
class student //定义 student类
{
friend class list; //声明 list 是 student的友元类
private:
char name[20];
double num;
double grade[4];
public:
student(){next=0;} //定义构造成员函数
void s(); //成员函数
student *next;
char * outname(){return name;};
double outgrade(int i){return grade[i];};
void intgrade(); //成员函数
};
void student::intgrade() //定义成员函数intgrade()
{ cout<<" 请输入语文成绩\n";//该成员函数实现成绩的输入
cin>>grade[0];
cout<<"请输入英语成绩\n";
cin>>grade[1];
cout<<"请输入数学成绩\n";
cin>>grade[2];
cout<<"请输入C++成绩\n";
cin>>grade[3];
}
void student::s() //定义成员函数s()
{
cout<<"请输入姓名\n"; //该函数实现多种数据的输入
cin>>name;
cout<<"请输入学号\n";
cin>>num;
cout<<"请输入语文成绩\n";
cin>>grade[0];
cout<<"请输入英语成绩\n";
cin>>grade[1];
cout<<"请输入数学成绩\n";
cin>>grade[2];
cout<<"请输入C++成绩\n";
cin>>grade[3];
}
class list //定义class类
{
private: //class类实现 功能
double high[5],low[5];
double totoal; //aver[3],pass[3],everygrade[3][6];
student *last,*first;
public:
list(){last=0;first=0;totoal=0;}; //定义初始值为0
~list(); //定义析构函数
void instu();
void outstu(char *);
int delstu(char *n);
void think();
void search(char s[10]);
double hi(int i);
double lo(int i);
void av(int i);
void ev(int i);
};
list::~list()//定义析构函数
{
if(first!=0)
{
student *p=first,*temp;
while(p!=0)
{
temp=p;
p=p->next;
delete temp;
cout<<"ok\n";
}
}
}
void list::instu() //定义成员函数instu()
{ student *p=new student(); //该函数实现数据的输入
p->s();
if(first==0){first=last=p;}else{last->next=p;last=p;}
totoal++;
}

void list::outstu(char *n) //定义成员函数outstu(char *n)
{
student *temp=first;for(;temp!=NULL;temp=temp->next) //查找选项并实现数据输出
if(strcmp(temp->outname(),n)==0)
{ cout<<"姓名 语文 英语 数学 C++ \n ";
cout<<temp->outname()<<" "<<temp->outgrade(0)<<" "<<temp->outgrade(1)<<
" "<<temp->outgrade(2)<<" "<<temp->outgrade(3);}////


}
int list::delstu(char *n) //定义成员函数delstu(char *n)
{
student *temp=first,*p;if(strcmp(first->outname(),n)==0)
{ first->next=first;delete temp;}
else if(temp->next!=0)
{if(strcmp(temp->next->outname(),n)==0)
{p=temp->next;temp->next=temp->next->next;delete p;}
else temp=temp->next;}
totoal--;
cout<<"\n删除成功\n";
return 0;
}
void list::think() //定义成员函数think()
{
cout<<"人数"<<totoal<<endl;
cout<<" 语文 、\n";
cout<<"最高分"<<hi(0)<<"最低分"<<lo(0)<<" ";
av(0);
ev(0);
cout<<"英语\n";
cout<<"最高分"<<hi(1)<<"最低分"<<lo(1)<<"  ";
av(1);
ev(1);
cout<<"数学、\n";
cout<<"最高分"<<hi(2)<<"最低分"<<lo(2)<<" ";
av(2);
ev(2);
cout<<"C++";
cout<<"最高分"<<hi(3)<<"最低分"<<lo(3)<<" ";
av(3);
ev(3);
}
double list::hi(int i)//定义成员函数hi(int i)
{
high[i]=0.00;
student *temp=first;
if(temp!=0)
{if(temp->outgrade(i)>high[i])
high[i]=temp->outgrade(i);
temp=temp->next;
}
return high[i];
}
double list::lo(int i)//定义成员函数lo(int)
{
low[i]=100;
student *temp=first;if(temp!=0)
{if(temp->outgrade(i)<low[i])
low[i]=temp->outgrade(i);
temp=temp->next;
}
return low[i];
}
void list::av(int i)//定义成员函数av(int i )
{ double aver=0;
student *temp=first;if(temp!=0)
{aver=temp->outgrade(i)+aver;
temp=temp->next;
}
cout<<aver/totoal<<endl;
}
void list::ev(int i)//定义成员函数ev(int i)
{ int a=0,b=0,c=0,d=0,e=0;
student *temp=first;if(temp!=0)
{switch((int)temp->outgrade(i)/10)
{
case 10:a++;break;case 9:a++;break;
case 8:b++;break;case 7:c++;break;
case 6:d++;break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:e++;break;
}
temp=temp->next;
}
cout<<"100-90、"<<a<<" "<<"89-80、"<<b<<" "<<"79-70、"<<c<<" "
<<"69-60、"<<d<<" "<<"60以下"<<e<<"及格"<<
(a+b+c+d)/(a+b+c+d+e)*100<<'%'<<endl;
}
void list::search(char s[10]) //定义成员函数search(char s[10])
{
student *temp=first;for(;temp!=NULL;temp=temp->next) //实现数据修改
if(strcmp(temp->outname(),s)==0)temp->intgrade();
}
#endif
void main() //输出界面
{
list will; //定义will为list的一个成员函数
int m=0;
do{
cout<<" 你现在看到的是学生成绩管理系统"<<endl;
cout<<"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
<<"输入1、 录入成绩:包括学生姓名和各门课程成绩的录入。 *\n"
<<"输入2、 查询成绩:可以根据姓名查询某个学生的成绩。 *\n"
<<"输入3、 修改成绩:可以根据姓名来修改相应的学生的成绩。 *\n"
<<"输入4、 删除成绩:可以指定删除某个学生的成绩。 *\n"
<<"输入5、 统计分析成绩:包括总人数、最高成绩、最低成绩、平均成绩、 *\n"
<<"各个分数段的人数(100-90、89-80、79-70、69-60、60以下)、及格率。 *\n"
<<"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; //输出界面
cin>>m; //输入数值
switch(m) //判别m,执行下面程序
{
case 1: //m=1时调用will.instu执行程序过程
will.instu();
break;
case 2: //m=2时调用will.outstu(n)执行程序过程
char n[9];
cout<<"请输入姓名\n";
cin>>n;
will.outstu(n);
cout<<"\n";
break;
case 3: //m=3时调用will.outstu(nb)和will.search(nb)执行程序过程
char nb[9];
cout<<"请输入姓名\n";
cin>>nb;
will.outstu(nb);
cout<<"\n";
will.search(nb);

break;
case 4: //m=4时调用will.outstu(naa)和will.delstu(naa)执行程序过程
char naa[9];
cout<<"请输入姓名\n";
cin>>naa;
will.outstu(naa);
will.delstu(naa);
break;


case 5: //m=5时调用will.think()执行程序过程
will.think();
break;
}
cout<<"1,继续2,退出\n";
cin>>m;
}
while(m==1); //m=1时循环上述过程
}

搜索更多相关主题的帖子: 英语 数学 总成绩 int 
2007-06-28 22:18
海子123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-7-1
收藏
得分:0 


把这段改一下
改成下面这样:
void list::think() //定义成员函数think()
{
list will;

cout<<"人数"<<totoal<<endl;
cout<<" 语文 、\n";
cout<<"最高分"<<will.hi(0)<<"最低分"<<will.lo(0)<<" ";
av(0);
ev(0);
cout<<"英语\n";
cout<<"最高分"<<will.hi(1)<<"最低分"<<will.lo(1)<<"  ";
av(1);
ev(1);
cout<<"数学、\n";
cout<<"最高分"<<will.hi(2)<<"最低分"<<will.lo(2)<<" ";
av(2);
ev(2);
cout<<"C++";
cout<<"最高分"<<will.hi(3)<<"最低分"<<will.lo(3)<<" ";
av(3);
ev(3);
}
看完知道那有问题了吧!


2007-07-01 15:39
long_557799
Rank: 1
等 级:新手上路
威 望:1
帖 子:284
专家分:0
注 册:2007-5-29
收藏
得分:0 
回复:海子123

我试过了
当我输入两个学生的数据如下:
liu
25
40
50
60
70

han
26
70
60
50
40
得出的结果如附件中的
我想应该是hi(int i)和lo(int i)出错吧

[此贴子已经被作者于2007-7-1 16:01:28编辑过]


Are you OK?
2007-07-01 15:55
long_557799
Rank: 1
等 级:新手上路
威 望:1
帖 子:284
专家分:0
注 册:2007-5-29
收藏
得分:0 
回复错人了

附件自己都没看到
所以我说下结果
结果如下
人数2
语文、
最高分0最低分100 20
100-90、0 89-80、0 79-70、0 69-60、0 60以下1及格0%
英语
最高分0最低分100 25
100-90、0 89-80、0 79-70、0 69-60、0 60以下1及格0%
数学、
最高分0最低分100 30
100-90、0 89-80、0 79-70、0 69-60、1 60以下0及格100%
C++最高分0最低分100 35
100-90、0 89-80、0 79-70、1 69-60、0 60以下及格100%

[此贴子已经被作者于2007-7-1 16:09:40编辑过]


Are you OK?
2007-07-01 15:57
海子123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-7-1
收藏
得分:0 

还需要考虑考虑

2007-07-02 23:06
long_557799
Rank: 1
等 级:新手上路
威 望:1
帖 子:284
专家分:0
注 册:2007-5-29
收藏
得分:0 
回复:(海子123)还需要考虑考虑

那就麻烦你了


Are you OK?
2007-07-02 23:15
海子123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-7-1
收藏
得分:0 

你在啊

2007-07-02 23:26
海子123
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-7-1
收藏
得分:0 
这个程序刚仔细看了下有很多问题

2007-07-02 23:27
long_557799
Rank: 1
等 级:新手上路
威 望:1
帖 子:284
专家分:0
注 册:2007-5-29
收藏
得分:0 
en


Are you OK?
2007-07-02 23:27
long_557799
Rank: 1
等 级:新手上路
威 望:1
帖 子:284
专家分:0
注 册:2007-5-29
收藏
得分:0 

基本功能能够实现


Are you OK?
2007-07-02 23:31
快速回复:[求助]懂VC的进来看下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.058790 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved