|
|
вернуться в форум1001 Crash HELP 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 Послано Noob 8 фев 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. |
|
|