|
|
вернуться в форумCRASH Could anyone help me? This code get CRASH... #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { // Input Database int num_elem_db; cin >> num_elem_db; vector<int> data_vector (num_elem_db, 0); // Vector for data for (int i = 0; i < num_elem_db; ++i) { int aux_elem; cin >> aux_elem; data_vector[i] = aux_elem; } cout << "###" << endl; // SORTING VECTOR OF DATA sort( data_vector.begin( ), data_vector.end( ) ); // Input queries int num_queries; cin >> num_queries; vector<int> query_vector (num_queries, 0); // Vector for queries for (int j = 0; j < num_queries; ++j) { int aux_query; cin >> aux_query; query_vector[j] = aux_query; } for (int k = 0; k < num_queries; ++k) { cout << data_vector[query_vector[k]-1] << endl; } return 0; } |
|
|