Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey for the life of me I can\'t figure this code out. 1. Take in a string, rever

ID: 3546407 • Letter: H

Question

Hey for the life of me I can't figure this code out.

1. Take in a string, reverse it using 2 pointers, one that points to the front and one to the back. Switch then and increment accordingly.

2. Create a class called list(you gotta do the class in another .h file and include it in the main) it should use a double variable to take in an array of numbers. Dynamic array btw. And then create default constrictor, para constructor, copy constructor along with the = overload and destructor.

Addlast, adds a number to the end of the list.

Getlast, returns number at end of the list.
Delete, delete last in list.
Isempty, check if list is empty.Overload <<operator.

Then make a test program for a list 1-20. Create another object of the class to take in that list backwards.(you need a "temp" object to do swapping) print all 3 objects using overloaded <<

Explanation / Answer

ANSWER FOR QUESTION NO. 1

#include<iostream>

#include<stdlib.h>

#include<string.h>

#include<conio.h>

#include<stdio.h>

using namespace std;

void reverse(char * f,char * e)

{

while(f<e)

{

char temp = *f;

*f = *e;

*e = temp;

f++;

e--;

}

}


int main()

{

char a[100];

gets(a);

int l = strlen(a);

char * front,* end;

front = a;

end = a+l-1;

reverse(front,end);

puts(a);

return 0;

}