本文整理汇总了C++中Student_info类的典型用法代码示例。如果您正苦于以下问题:C++ Student_info类的具体用法?C++ Student_info怎么用?C++ Student_info使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Student_info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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() << " completed the thesis(for graduate) or homework(for undergraduate)?";
if (students[i].complete()) {
cout << " yes" ;
cout << " grade: " << students[i].grade() << " " << students[i].letter_grade() << 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: main
int main() {
try {
Student_info record;
record.grade();
} catch (domain_error e) {
cout << e.what() << endl;
}
return 0;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: grade_aux
double grade_aux(const Student_info& s)
{
return s.grade();
}
示例12: average_grade
double average_grade(const Student_info& s)
{
return s.average_grade();
}
示例13: fgrade
bool fgrade(Student_info& s)
{
return s.grade() < 60;
}
示例14: did_all_hw
bool did_all_hw(const Student_info& s)
{
return s.valid();
}
示例15: compare
bool compare(const Student_info& x, const Student_info& y)
{
return x.name() < y.name(); // Modified for class Student_info Ch. 9
}