|
|
вернуться в форумVisual C++ 2010, Runtime error (access violation) Could someone help me ? #include <iostream> #include <iomanip> using namespace std; int main() { double outputNumbers[100000]; double number; int index; index = -1; while (cin.fail() == false) { cin >> outputNumbers[++index]; }
cout << fixed; cout << setprecision(4);
while (index > 0) { cout << sqrt(outputNumbers[--index]) << endl; } return 0; } Re: Visual C++ 2010, Runtime error (access violation) I have rewrite the program, using vectors but now I receive wrong answer... #include <iostream> #include <iomanip> #include <vector> using namespace std; int main() { vector<double> myVector; double value; while (cin.fail() == false) { cin >> value; myVector.push_back(sqrt(value)); }
myVector.pop_back(); cout << fixed; cout << setprecision(4); for (int i = 0; i < myVector.size(); i++) { cout << myVector[i] << endl; } return 0; } |
|
|