// Program to read in integers and print in two columns. // // Input: sequence of N integers read from standard input. // Output: input sequence of integers printed to standard output in // two-column format, with first column containing first // (N+1)/2 numbers and second column containing remaining // numbers. // // This version uses the STL. #include #include // has EXIT_SUCCESS #include typedef vector::size_type v_size_t; int main(void) { vector v; int temp; cout << "Enter some integers, control-D to end:\n"; while (cin >> temp) v.push_back(temp); v_size_t size = v.size(); // to save a little typing for (v_size_t i = 0; i < size/2; ++i) cout << v[i] << "\t" << v[i + (size+1)/2] << endl; if (size % 2 != 0) cout << v[size/2] << endl; return EXIT_SUCCESS; }