#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
int ch;
int row=1;
int column=1;
infile.open("a.txt");
while((ch=infile.get())!=EOF)
{
column++;
if(ch==10)
row++;
}
column=column=column/2/row;
infile.close();
infile.clear();
infile.open("a.txt");
int **a=new int *[row];
for(int i=0;i<row;++i)
a[i]=new int[column];
int m=0;
int n=0;
while(infile>>a[m][n])
{
++n;
if(n%3==0)
{
++m;
n=0;
}
}
infile.close();
outfile.open("c.txt");
for(i=0;i<row;++i)
{
for(int j=0;j<column;++j)
outfile<<a[i][j]<<" ";
outfile<<endl;
}
for(i=0;i<row;++i)
delete [] a[i];
delete []a;
a=NULL;
return 0;
}
posted on 2011-12-23 09:41
烈焰之光 阅读(100)
评论(0) 编辑 收藏 引用 所属分类:
源码 、
文件及文件夹操作