天狼啸月
天狼神族
posts - 0,  comments - 0,  trackbacks - 0
#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)  编辑 收藏 引用 所属分类: 源码文件及文件夹操作

<2026年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿

文章分类

文章档案

搜索

  •  

最新评论