Re: Why Crash?
Posted by
Tirex 29 Jun 2009 04:19
Decided. Please explain some of the time, please.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
typedef unsigned long long Beta;
int main()
{
const unsigned int N=128*1024;
Beta *xl=new Beta[N];
int col=0;
cin.setf(ios::skipws);
while(cin>>xl[col]) col++;
cout.unsetf(cout.flags());
cout.setf(ios::showpoint|ios::fixed|ios::dec);
while(col--) cout<<setprecision(4)<<sqrt((double)xl[col])<<endl;
delete []xl;
return 0;
}
The size of the input stream 256 kb.
So we need to allocate memory in the amount of (256*1024)/sizeof(_int64);
Why is the correct decision should be 128 * 1024?