注册 登录
编程论坛 C++教室

求一个班的学生成绩

宇智波曌 发布于 2011-05-09 13:36, 914 次点击
1、输入每个学生的四门成绩;
2、计算每个学生的平均分和总分;
3、输出每门不及格的学生成绩。
请问用一个程序怎么写?
11 回复
#2
hellovfp2011-05-09 13:37
用手+你的头脑写。
#3
棉雨2011-05-09 13:40
回复 2楼 hellovfp
有点搞笑。
#4
hellovfp2011-05-09 13:45
回复 3楼 棉雨
呵呵,坛子里懒人太多了。有点搞笑,但却是实情。
#5
棉雨2011-05-09 14:23
回复 楼主 宇智波曌
我做了一下,不知道是不是你想要的,仅供参考。
#include"iostream"
#define MaxSize 100
using namespace std;
class Student
{
private:
    float score[4];
    float avge;
    float sum;
public:
    void set_score()
    {
        int i;
        cout<<"please input the score :"<<endl;
        for(i=0;i<4;i++)
            cin>>score[i];
    }
    void calculate()
    {
        int i;
        sum=0;        
        for(i=0;i<4;i++)
            sum+=score[i];
        avge=sum/4;
        cout<<"总和是:"<<sum<<"平均值是:"<<avge<<endl;
        
        for(i=0;i<4;i++)
            if((score[i]>=0)&&(score[i]<60))
                cout<<score[i]<<" ";
            cout<<endl;
    }
};
void main()
{
    Student student[MaxSize];
    int n,i;
    cout<<"请输入学生人数:"<<endl;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cout<<"请输入第"<<i<<"个学生的成绩:"<<endl;
        student[i].set_score();
        student[i].calculate();
    }
}
#6
shiyuedef2011-05-09 19:37
支持,加油
#7
宇智波曌2011-05-09 21:09
回复 5楼 棉雨
虽然不是我想要的,但还是谢谢你了!
#8
h3634569742011-05-10 02:09
  好好学习  天天向上!!!
#9
烟雾中的迷茫2011-05-10 06:34
搂住要尽量自己写啊我上次自己写了个这样类似的已经发到这论坛了  其实还是自己动脑比较好 能锻炼自己
#10
宇智波曌2011-05-10 12:44
回复 9楼 烟雾中的迷茫
谢谢你的建议 !
#11
donggegege2011-05-10 22:45
五楼不错
#12
宇智波曌2011-05-11 11:51
回复 5楼 棉雨
这个程序里的 《 是什么意思啊?
1