My function needs to print out:
TACMAN
ATCMAN
CTAMAN
TCAMAN
ACTMAN
CATMAN
Two functions required are:
1) void string::insert(size_type position, size_type number_of_copies, char c);
2) void string::erase(size_type position, size_type n)
Other functions I may need:
3) Do I need to use a permute function and a dopermute function? How do I make the permute functions part of my program by using insert and erase?
Expand|Select|Wrap|Line Numbers
- using namespace std;
- void string::insert(size_type position, size_type number_of_copies, char c)
- {
- string s1 = "CAT";
- string s2 = "MAN";
- //add or insert CAT to first 3
- //add or insert MAN to last 3
- //then...
- //...add TA and insert with CMAN = "TACMAN"
- //..replace TA with AT and insert with CMAN = "ATCMAN"
- //..call erase c();
- //add CT and insert with AMAN = "CTAMAN"
- //..replace CT with TC and insert with AMAN = "TCAMAN"
- //..call erase c();
- //add AC and insert with TMAN = "ACTMAN"
- //..replace AC with CA and insert with TMAN = "CATMAN"
- //postcondition: The specified number of copies of c have been
- //inserted into the string at the indicated position.
- //Existing characters that used to be at or after the given position have been shifted right
- //one spot
- }
- void string::erase(size_type position, size_type n)
- {
- // delete c[]; or c[] = NULL;
- }
- int main()
- {
- char c[5];
- insert(,,); //First function call, so it starts at one
- }
Thank you.