文件中格式如下:

4
3
34.4 3.2 9.4
8.43 23.23 2.3
43.4 43.1 9.3
9.8 7.4 1.3

 

View Code
#include <fstream>
#include <fstream>
#include <iostream>
using namespace std;

int main()
{
    int n,m;
    ifstream fin("D:\训练样本集文件.txt");
        fin>>n;//文件的第一个作为数组数据个数 
        fin>>m;//文件的第二个作为样本维数 
    double a[n][m];
    for(int i=0;i<n;i++)
       for(int j=0;j<m;j++)
        fin>>a[i][j];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
          cout<<a[i][j]<<" ";
        cout<<endl;
    }
       
       

    //ofstream fout("D:/我的输出文件.txt");
    //fout<<"现在输出到文件中了,是吗?";
    fin.close();
    //fout.close();
    cin.get();
    return 0;
}

 

 

相关文章:

  • 2021-11-16
  • 2022-12-23
  • 2021-06-22
  • 2022-01-20
  • 2022-01-19
  • 2021-09-02
猜你喜欢
  • 2021-07-24
  • 2021-11-23
  • 2022-12-23
  • 2021-11-11
  • 2021-08-29
  • 2021-11-14
  • 2022-01-23
相关资源
相似解决方案