Question
Write a function with this prototype: #include void numbers(ostream& outs, const String& prefix, unsigned int levels); The function prints output to the ostream outs. The
Write a function with this prototype:
#include
void numbers(ostream& outs, const String& prefix, unsigned int levels);
The function prints output to the ostream outs. The output 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 "THERBLIG" and levels is 2, then the function would start by printing:
THERBLIG1.1.
THERBLIG1.2.
THERBLIG1.3.
and end by printing:
THERBLIG9.7.
THERBLIG9.8.
THERBLIG9.9.
The stopping case occurs when levels reaches zero (in which case the prefix is printed once by itself followed by nothing else).
The String class from
s = (prefix + c) + '.';
This new String s can be passed as a parameter to recursive calls of the function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started