ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

Crash ( access violation ) why ?
Posted by diviator 19 Mar 2012 18:09
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    ifstream f("input.txt");
    ofstream o("output.txt");
    int n=0;
    long double a[100];
    long double k;
    f >> k;
    while(!f.eof())
    {
    a[n] = sqrt(k);
    n++;
    f >> k;
    }

    for ( int i=n-1 ; i >= 0 ; i-- )
    o << fixed << setprecision(4) << a[i] << endl;
    return 0;
}
Re: Crash ( access violation ) why ?
Posted by Thien Diep 25 Jun 2012 21:42
size of array a = 100 is not enought to solve a[i]. size of array maybe more than 1 million double :D I think so


Edited by author 25.06.2012 21:43
Re: Crash ( access violation ) why ?
Posted by Smilodon_am [Obninsk INPE] 26 Jun 2012 12:59
Thien Diep wrote 25 June 2012 21:42
size of array maybe more than 1 million double :D I think so

size of array maybe not more than 131072 values
Re: Crash ( access violation ) why ?
Posted by Thien Diep 26 Jun 2012 13:09
Smilodon_am [Obninsk INPE] wrote 26 June 2012 12:59
size of array maybe not more than 131072 values
So that couldn't use array to save