文本超5G,数组过大,运行则秒退
需要处理的文本超过5G,数据输入形成的数组有超过九千万,运行则秒退,请问该如何处理?warning LNK4084: total image size -1609625600 exceeds max (268435456); image may not run
程序如下:
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
char s_sta[98297160], s_s_t[98237160];
int s_num[98297160], depth[98297160];
float Q[98297160], hh[98297160],ii[98297160],jj[98297160];
char b_name[44422], b_sta[44422], aa[44422], bb[44422], cc[44422], b_s_t[44422], ff[44422],gg[44422];
int num[44422], b_c_t[44422];
float dd[44422],ee[44422];
char k_name[10000000], k_sta[10000000], k_t[10000000];
int k_d[10000000];
float k_Q[10000000];
int main()
{
fstream fin("土壤水份站近3年逐小时资料.txt",ios::in);//打开输入文件
fstream precipitation("微量降水B1.txt",ios::in);
fstream outfile("B1.txt");// 打开文件
ofstream lastfile("微量降水(降水总量=3mm)过程中土壤含水量变化分析.txt",ios::trunc|ios::out);// 打开输出文件
if(!fin)
{
cerr<<"can not open file"<<endl;
return -1;
}
if(!precipitation)
{
cerr<<"can not open file"<<endl;
return -1;
}
if(!outfile)
{
cerr<<"can not open file"<<endl;
return -1;
}
if(!lastfile)
{
cerr<<"can not open file"<<endl;
return -1;
}
int i,j,k;
//输入表1逐日数据
for(i=0;i<98297161;i++)
{
if(i == 0)
{
continue;
}
fin>>s_sta[i], s_s_t[i], s_num[i], depth[i], Q[i], hh[i], ii[i], jj[i];
i++;
}
//输入表2降水数据
for(j=0;j<44423;j++)
{
if(j == 0)
{
continue;
}
precipitation>>num[j],b_name[j],b_sta[j],aa[j],bb[j],cc[j],b_s_t[j],b_c_t[j],dd[j],ee[j],ff[j],gg[j];
j++;
if(j == 10)
{
cout << "j==10" << endl;
}
}
//输出提取的数据到outfile
for(j=0;j<44423;j++)
{
for(i=0;i<98297161;i++)
{
while((b_sta[j] == s_sta[i]) && (b_s_t[j] == s_s_t[i]))
{
for(i=i-60;i<=i+500;i++)
{
while((depth[i]==10)||(depth[i]==20)||(depth[i]==30)||(depth[i]==40)||(depth[i]==50)||(depth[i]==60)||(depth[i]==80)||(depth[i]==100))
{
outfile<<b_name[j]<<s_sta[i]<< s_s_t[i]<< depth[i]<< Q[i]<<endl;
}
i++;
}
}
break;
}
j++;
}
//对outfile数据整理排序输出到lastfile
for(k=0;k<10000000;k++)
{
outfile>>k_name[k],k_sta[k],k_t[k],k_d[k],k_Q[k];
k++;
}
for(k=0;k<10000000;k=k+8)
{
lastfile<<k_name[k]<<k_sta[k]<<k_d[k]<<k_Q[k]<<k_Q[k+1]<<k_Q[k+2]<<k_Q[k+3]<<k_Q[k+4]<<k_Q[k+5]<<k_Q[k+6]<<k_Q[k+7]<<k_Q[k+8]<<k_Q[k+9]<<k_Q[k+10]
<<k_Q[k+11]<<k_Q[k+12]<<k_Q[k+13]<<k_Q[k+14]<<k_Q[k+15]<<k_Q[k+16]<<k_Q[k+17]<<k_Q[k+18]<<k_Q[k+19]<<k_Q[k+20]<<k_Q[k+21]<<k_Q[k+22]<<k_Q[k+23]
<<k_Q[k+24]<<k_Q[k+25]<<k_Q[k+26]<<k_Q[k+27]<<endl;
k=k+8;
}
fin.close();
precipitation.close();
outfile.close();
lastfile.close();
return 0;
}