当前位置: 首页>>代码示例>>C++>>正文


C++ Student_info::read方法代码示例

本文整理汇总了C++中Student_info::read方法的典型用法代码示例。如果您正苦于以下问题:C++ Student_info::read方法的具体用法?C++ Student_info::read怎么用?C++ Student_info::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Student_info的用法示例。


在下文中一共展示了Student_info::read方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{

	vector<Student_info> students;
	Student_info record;
	string::size_type maxlen = 0;
	
	while(record.read(cin)) {
		maxlen = max(maxlen,record.name().size());
		students.push_back(record);
	}

	sort(students.begin(),students.end(),compare);
	for(int i=0;i<students.size();++i) {
		cout << students[i].name()
			<< string(maxlen+1-students[i].name().size(),' ');
		try {
			double finalgrade = students[i].grade();
			cout << setprecision(3) << finalgrade << endl;
		} catch (domain_error e) {
			cout << e.what() << endl;
		}
	}

	return 0;
}
开发者ID:hiddevuijk,项目名称:accelerated_C-,代码行数:26,代码来源:main.cpp

示例2: main

int main()
{
	vector<Student_info> students;
	Student_info record;
	string::size_type maxlen = 0;

	// read and store the data
	while (record.read(cin)) {
		maxlen = max(maxlen, record.name().size());
		students.push_back(record);
	}

	// alphabetize the student records
	sort(students.begin(), students.end(), Student_info::compare);

	// write the names and grades
	for (vector<Student_info>::size_type i = 0;
	     i != students.size(); ++i) {
		cout << students[i].name()
		     << string(maxlen + 1 - students[i].name().size(), ' ');
		try {
			double final_grade = students[i].grade();
			streamsize prec = cout.precision();
			cout << setprecision(3) << final_grade
			     << setprecision(prec) << endl;
		} catch (domain_error e) {
			cout << e.what() << endl;
		}
	}
	return 0;
}
开发者ID:arraytools,项目名称:C,代码行数:31,代码来源:main_orig.cpp

示例3: main

int main()
{
    // students who did and didn't do all of their homework
    vector<Student_info> did, didnt;

    // read the students records and partition them
    Student_info student;
    while (student.read(cin)) {
        if (student.did_all_hw())
            did.push_back(student);
        else
            didnt.push_back(student);
    }

    // verify that the analysis 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);

    return 0;
}
开发者ID:yellowjacket05,项目名称:AcceleratedCppExercises,代码行数:31,代码来源:11-5.cpp

示例4: main

int main(int argc, const char *argv[])
{
    vector<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;

    while (record.read(cin)) {
        students.push_back(record);
        maxlen = max(maxlen, record.name().size());
    }

    for (vector<Student_info>::size_type i = 0; i != students.size(); i++) {
        cout << "Has student " << students[i].name() << " made any work?";
            if (students[i].valid()) {
                cout << " yes" << endl;
            } else {
                cout << " no" << endl;
            }
    }
    Core c1;
    c1.valid();
    cout << "Has student c1 made any work?";
    if (c1.valid()) {
        cout << " yes" << endl;
    } else {
        cout << " no" << endl;
    }

    return 0;
}
开发者ID:chibby0ne,项目名称:AcceleratedC,代码行数:30,代码来源:exercise3.cpp

示例5: main

int main(int argc, const char *argv[])
{
    Vec<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;

    while (record.read(cin)) {
        maxlen = max(maxlen, record.name().size());
        students.push_back(record);
    }

    //  
    sort(students.begin(), students.end(), compare);

    for (Vec<double>::size_type i = 0; i != students.size(); i++) {
        cout << students[i].name() << string(maxlen + 1 - students[i].name().size(), ' ');
        try {
            double final_grade = students[i].grade();
            streamsize prec = cout.precision();
            cout << setprecision(3) << final_grade << setprecision(prec) << endl;
        } catch (domain_error e) {
            cout << e.what() << endl;
        }
    }
    return 0;
}
开发者ID:chibby0ne,项目名称:AcceleratedC,代码行数:26,代码来源:exercise7.cpp

示例6: main

int main()
{
    vector<Student_info> students;
    Student_info s;

    while(s.read(cin))
        students.push_back(s);

    sort(students.begin(), students.end(), Student_info::compare);

    cout << frame(histogram(students)) << endl;
    return 0;
}
开发者ID:jollywing,项目名称:jolly-code-snippets,代码行数:13,代码来源:main.cpp

示例7: main

int main()
{

    // students who did and didn't do all of their hw
    vector<Student_info> did, didnt;

    // read the student records and partition them
    Student_info student;
    while (student.read(cin)) {
        if (did_all_hw(student))
            did.push_back(student);
        else
            didnt.push_back(student);
    }

    // check that both groups contain data
    //if (did.empty()) {
        //cout << "No student did all the homework!" << endl;
        //return 1;
    //}
    //if (didnt.empty()) {
        //std::cout << "Every student did all the homework!" << std::endl;
        //return 1;
    //}

    // do the analysis
    write_analysis(cout, "median", grade_aux, did, didnt);
    cout << "Created: " << Student_info::num_create << endl;
    cout << "Copied: " << Student_info::num_copy << endl;
    cout << "Destroyed: " << Student_info::num_destr << endl;
    cout << "Assigned: " << Student_info::num_asmt << endl;
    write_analysis(cout, "average", average_grade, did, didnt);
    cout << "Created: " << Student_info::num_create << endl;
    cout << "Copied: " << Student_info::num_copy << endl;
    cout << "Destroyed: " << Student_info::num_destr << endl;
    cout << "Assigned: " << Student_info::num_asmt << endl;
    write_analysis(cout, "median of hw turned in", optimistic_median, did, didnt);
    cout << "Created: " << Student_info::num_create << endl;
    cout << "Copied: " << Student_info::num_copy << endl;
    cout << "Destroyed: " << Student_info::num_destr << endl;
    cout << "Assigned: " << Student_info::num_asmt << endl;

    return 0;
}
开发者ID:ctasims,项目名称:accelerated-cpp,代码行数:44,代码来源:grader.cpp

示例8: main

int main()
{
    vector<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;   // the length of the longest name

    // read input file (added for 13-1)
    ifstream studentFile("students.txt");

    // read and storea all the student's data
    // Invariant: students contains all the student records read so far
    //            maxlen contains the length of the longest name in students
    while (record.read(studentFile)) { // Modified for class Student_info Ch. 9
        // find length of the longest name
        maxlen = max(maxlen, record.name().size());
        students.push_back(record);
    }

    cout << "sort function" << endl;
    // alphebetize the student records
    sort(students.begin(), students.end(), Student_info::compare);

    cout << "write loop" << endl;
    // write the names and grades
    for (vector<Student_info>::size_type i = 0; i != students.size(); i++) {
        // write the name, padded on the right to maxlen + 1 characters
        cout << students[i].name() << string (maxlen + 1 - students[i].name().size(), ' ');
        string validity = students[i].valid() ? "valid" : "not valid";
        cout << validity << endl;

        // compute and write the grade
        try {
            double final_grade = students[i].grade();
            streamsize prec = cout.precision();
            cout << setprecision(3) << final_grade
                    << setprecision(prec) << endl;
        } catch (domain_error e) {
            cout << e.what() << endl;
        }
    }

    return 0;
}
开发者ID:yellowjacket05,项目名称:AcceleratedCppExercises,代码行数:43,代码来源:13-3main.cpp

示例9: main

int main(int argc, const char *argv[])
{
    vector<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;

    while (record.read(cin)) {
        students.push_back(record);
        maxlen = max(maxlen, record.name().size());
    }

    
    cout << "student " << students[0].name() << " grade: " << students[0].grade() << " " << students[0].letter_grade() << endl;
    cout << "student " << students[1].name() << " grade: " << students[1].grade() << " " << students[1].letter_grade() << endl;
    cout << "student " << students[2].name() << " grade: " << students[2].grade() << " " << students[2].letter_grade() << endl;
    cout << "student " << students[3].name() << " grade: " << students[3].grade() << " " << students[3].letter_grade() << endl;
    cout << "student " << students[4].name() << " grade: " << students[4].grade() << " " << students[4].letter_grade() << endl;
    cout << "Has student " << students[4].name() << " passed?";
    if (students[4].grade() >= 60) {
        cout << " yes" << endl;
    } else {
        cout << " no" << endl;
    }
    cout << "student " << students[5].name() << " grade: " << students[5].grade() << " " << students[5].letter_grade() << endl;
    cout << "Has student " << students[5].name() << " passed?";
    if (students[5].grade() >= 60) {
        cout << " yes" << endl;
    } else {
        cout << " no" << endl;
    }
 
    Core c1;
    c1.valid();
    cout << "Has student c1 made any work?";
    if (c1.valid()) {
        cout << " yes" << endl;
    } else {
        cout << " no" << endl;
    }

    return 0;
}
开发者ID:chibby0ne,项目名称:AcceleratedC,代码行数:42,代码来源:exercise6.cpp


注:本文中的Student_info::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。