Accelerated C++ Exercise 6-0 (分析成绩)

本文通过编程实现了一个系统,用于读取学生记录并分析哪些学生完成了所有家庭作业,哪些没有。系统提供了中位数、平均数和乐观中位数分析,并验证了学生作业完成情况的数据。最终通过命令行输出了分析结果。
#include <vector>   
#include <iostream>   
   
#include "analysis.h"   
#include "Student_info.h"   
   
using std::cin;   
using std::cout;   
using std::endl;   
using std::vector;   
   
int main()   
{   
    // students who did and didn't do all their homework   
    vector<Student_info> did, didnt;   
   
    // read the student records and partition them   
    Student_info student;   
    while (read(cin, student)) {   
        if (did_all_hw(student))   
            did.push_back(student);   
        else   
            didnt.push_back(student);   
    }   
   
    // verify that the analyses will show us something   
    if (did.empty()) {   
        cout << "No student did all the homework!" << endl;   
        return 1;   
    }   
    if (didnt.empty()) {   
        cout << "Every student did all the homework!" << endl;   
        return 1;   
    }   
   
   
    // do the analyses   
    write_analysis(cout, "median", median_analysis, did, didnt);   
    write_analysis(cout, "average", average_analysis, did, didnt);   
    write_analysis(cout, "median of homework turned in",optimistic_median_analysis, did, didnt);   
	system("pause");
    return 0;   
}   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值