// 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 using namespace std; typedef unsigned int size_t; int main(void) { // vector v; const size_t maxSize = 10; // maximum size of v size_t size = 0; // size of v int v[maxSize]; int temp; cout << "Enter some integers, control-D to end:\n"; while (cin >> temp) { if (size == maxSize) { cout << "You have exceeded this program's capacity!\n"; exit(EXIT_FAILURE); } //v.push_back(temp); ++size; v[size-1] = temp; } // size_t size = v.size(); for (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; }