// 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 does not use the STL, but uses a fixed-size array. #include #include // has EXIT_SUCCESS typedef unsigned int v_size_t; int main(void) { // vector v; const v_size_t maxSize = 10; // maximum size of v v_size_t size = 0; // size of v int v[maxSize]; cout << "Enter some integers, control-D to end:\n"; while (size < maxSize && cin >> v[size]) { ++size; //v.push_back(temp); } int temp; if (cin >> temp) { cout << "You have exceeded this program's capacity!\n"; exit(EXIT_FAILURE); } // v_size_t size = v.size(); 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; }