Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Program: fill2.cpp // define and use a function to fill a range #include // PRE: [begin, end) is a valid range // POST: *p is set to value, for p in [begin, end) void fill (int* begin, int* end, const int value) { for (int* ptr = begin; ptr != end; ++ptr) *ptr = value; } int main() { int a[5]; fill (a, a+5, 1); for (int i=0; i<5; ++i) std::cout << a[i] << " "; // 1 1 1 1 1 std::cout << "\n"; return 0; }