123456789101112131415161718192021222324252627282930313233343536373839404142
#include <iostream> #include <vector> #include <stdexcept> using namespace std; void error(string err) { throw runtime_error(err); } int main() { try{ vector<double>v; double x; while(cin>>x) { if(x == 00) break; v.push_back(x); } if(!cin) error("couldn't read a double for input"); for(unsigned int i=0;i<=v.size();++i) cout<<"v["<<i<<"]=="<<v[i]<<endl; } catch(exception& e) { cerr<<"Runtime error: "<<e.what()<<"\n"; cin.get(); return 1; } catch(...) { cerr<<"OOpsie! Unknown exception!\n"; cin.get(); return 2; } }
cout<<"v["<<i<<"]=="<<v.at(i)<<endl;