recursion assignment

CAN SOMEONE PLEASE HELP ME WITH THIS ASSIGNMENT!!!
I TRIED TO WRITE SOMETHIHNG AND NOTHING WORKED!!!
HELP!!!
III. Write a recursive function with this prototype:
void numbers(string prefix, int levels);
The function prints output that consists of the string prefix followed by "section numbers" of the form 1.1., 1.2., 1.3., and so on. The levels argument determines how may levels the section numbers have. For example, if levels is 2, then the section numbers have the form x.y. If levels is 3, then section numbers have the form x.y.z. The digits permitted in each level are always '1' through '9'. As an example, if prefix is the string "Section" and levels is 2, then the function would start by printing:
Section1.1.
Section1.2.
Section1.3.
and end by printing:
Section9.7.
Section9.8.
Section9.9.
The stopping case occurs when levels reaches zero (in which case the prefix is printed once by itself followed by nothing else).

Use the sstream library to build the prefix. For example,
#include <sstream>
ostringstream ss;
int i = 5;
string prefix = “abc”;
ss << prefix << i;
prefix = ss.str();
cout << prefix; // will print abc5

Topic archived. No new replies allowed.