C++ 高分

来源:百度知道 编辑:UC知道 时间:2024/04/30 10:23:35
#include<iostream>
#include<fstream>
using namespace std;
void main(void)
{
float line[3][7];
float m;
int i=0,j=0;
ifstream fin("M:\\D.dat");
while(! fin.eof() )
{
fin>>m;
line[i][j]= m;/*give the int number to the array*/
j++; /*prepare for next int number*/
}
fin.close();
for (i=0;i<3;i++)
{
for (j=0;j<7;j++)
{
cout << line[i][j];
}
}
}
帮忙找一下错阿
呵呵 好的 忘了
24 26 25 27 31 29 26.5
23.0 22.5 23 24.6 25.2 22.9 21.1
27 22 23 26.7 29 26.9 30.0

请提供你所使用的数据文件d.dat
*******************************************
修改如下:

//---------------------------------------------------------------------------
#include<iostream>
#include<fstream>
using namespace std;
void main(void)
{
float line[3][7];
float m;
int i=0,j=0;
ifstream fin("M:\\d.dat");
while(! fin.eof() )
{
fin>>m;
line[i][j]= m;/*give the int number to the array*/
j++; /*prepare for next int number*/
if (j==7) { /*注意这里*/
j=0;
++i;
}
}
fin.close();
for (i=0;i<3;i++)
{
for (j=0;j<7;j++)
{
cout << line[i][j]<<'\t'; /*注意这里*/
}
}
}
//---------------------------------------------------------------------------

#include<iostream>
#include<fstream>
using namespace std;
void main(void)
{
float l