forked from chihyang/CPP_Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer06_47.cpp
More file actions
30 lines (30 loc) · 737 Bytes
/
Copy pathExer06_47.cpp
File metadata and controls
30 lines (30 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <vector>
#include <cassert>
using std::cout;
using std::cerr;
using std::endl;
using std::vector;
void printVec(const vector<int> &vec, int beg, int size)
{
if(vec.empty())
return;
if(size - beg > 0)
{
#ifndef NDEBUG
cerr << "\n" << __FUNCTION__ << ":\n"
<< "The size of the vector:" << size - beg << endl;
#endif
cout << vec[beg] << " ";
printVec(vec, ++beg, size);
}
}
int main()
{
vector<int> vi = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
printVec(vi, 0, vi.size());
cout << endl;
return 0;
}
// Note: for visual studio compiler, substitute __FUNCTION__ for __func__,
// for g++, both __FUNCTION__ and __func__ are okay.