txt 转成 other
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
string buf;
ifstream in("magic.txt");
cout<< "magic(4) = "<<endl;
int i = 0;
int arr[4][4];//可以转为动态
istringstream istr;
while(getline(in,buf)){
istr = istringstream(buf);
int j = 0;
char ch;
while(istr) {istr >>arr[i][j++];}
++i;
//输出数组
j = 0;
while(j<4){
cout << arr[i][j] <<" ";
j++;
}
cout << endl;
}
}
2万+

被折叠的 条评论
为什么被折叠?



