早教吧 育儿知识 作业答案 考试题库 百科 知识分享

Writeaprogramtoread10namefromandinputfile,eachnamehas5grades(fromanotherinputfile)nowdisplayandprintthemtoanoutputfile.Sendinputfiles,sourcecode,andoutputfileforgrading写个程序从一个input文件里读名字(1

题目详情
Write a program to read 10 name from and input file,each name has 5 grades (from another input file)
now display and print them to an output file.Send input files,source code,and output file for grading
写个程序从一个input文件里读名字(10)个,每个名字有5个成绩(来自另一分input 文件),显示他们并print在output的文件里
▼优质解答
答案和解析

老兄,这个要根据你两个input文件的格式来读取信息.然后组织在一起.

如果不知道格式,什么事情也做不了.

你得告诉我,格式是什么样子的. 下面就是简单的一个类.

实现的话,必须要根据两个input的格式,以及你期望的output的格式.

struct student
{
    string _name;
    // one student has five grade.
    float _grade[5];
};

class StudentManager
{
   public: 
    // get info from the input file.
    void ReadNameFromFile( const char *filename);

    // get grades from the input file.
    void ReadGradesFromFile( const char *filename);

    // Out put the infomation.
    void OutPutInfo( const char* outputFileName );

private:
     // only 10 studtent
      student m_student10];

};