将存放在源文件中的学生成绩读入二维整型数组 m[3][5]中,数组 m 的第 0 列 存放学号,第 4 列存放平均成绩。计算出每个学生的平均成绩,将数组 m 按平 均成绩升序排列后,输出显示到显示器上。 源文件内容如下:
#include <iostream>
#include<fstream>
#include<iomanip>
using namespace std;
void run1()
{
int a[12]={
1001,90,85,80,1002,78,70,62,1003,75,72,69};
ofstream outfile("d:\\score.txt",ios::out);
if(!outfile)
{
cout<<"run1失败"<<endl;
}
for(int i=0;i<12;i++)
{
outfile.write((char*)&a[i],sizeof(a[i]));
}
outfile.close();
}
void run_average()
{
int j=1,b[12],a[3],aver;
ofstream file1("d:\\average.txt",ios::out);
if(!file1)
{
cout<<"run_average失败"<<endl;
}
ifstream file2("d:\\score.txt"