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

1001 Crash HELP
Posted by Visual_Studio2010 7 Feb 2011 23:57
I used the vector to solve this problem, but the system told me "Crash".
I want to know why, so sent help to you, thank you.

Below is my solution:
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
    vector<double> doubleVector;
    int i = 0;
    double cinVector = 0;

    // Read in numbers
    while (cin >> cinVector)
    {
        doubleVector.push_back(cinVector);
        i++;
    }

    // Display the results
    while (i > 0)
    {
        cout << sqrt(doubleVector.at(i)) << endl;
        i--;
    }

    return 0;

}




In addition, what will cause the "Crash"?

Edited by author 07.02.2011 23:58
Re: 1001 Crash HELP
Posted by Noob 8 Feb 2011 01:55
Input: n numbers

After 1st while cycle: i = n

doubleVector.at(i) - crash because size = n and only doubleVector[n-1] exists.

And you should print numbers with 4 digits after the decimal point.