can you help me plz in these 2 assignments:
assignment1:
Create a new string ADT (using a dynamic array).
The data members of the String class are a pointer to the start of your string and an integer representing the length of that string. The following methods should be provided:
- Default constructor.
- Initialization constructor.
- Copy constructor.
- Destructor
- A function called
getLength()
that returns the length of the string. - A function called
getString()
that sets the string. - A function called
searchString_Ch()
that searches the master string for a specific characters. If searched character is found, appropriate message should be printed out along with its position. Otherwise, message not found is printed out. - A function called
search_Sub()
that searches the master string for specific substring "ss". If searched character is found, appropriate message should be printed out along with its position. Otherwise, message not found is printed. - A function that called
insertString()
that inserts a substring "ss" at a given position POS in the master string. - A function called
moveString()
that moves a substring "ss" (if found in the master string) to the end of the master string. - A function called
replaceString()
that replaces all occurrences of substring, say "ss" (is found in the master string), by another substring, say "tt". The function must return the position POS of the sub string if it is found or return 0 if the substring was not found. - Overload the function operators:
!
( to test if string is empty),+=
(to concatenate 2 strings);==
(to test equality);=
(to assign a string s2 to string s1)
Assignment2:
Create a user-defined structure type Array with only 2 integer members:
An array a[]
of integer numbers.
Integer variable called size that refer to the actual dimension of the array a[ ]
.
Write a c program that defines a single array structure (object) called Arrayoper. Provide functions that perform the following operations on the array a[]
:
- A user-defined function called
setArray( )
to assign values for the arraya[ ]
. - A user-defined function called
addArray( )
to add any 2 arraysx[ ]
andy[ ]
and store the result on arrayz [ ]
. - A user-defined function called
Maxarray( )
to find the maximum element of an array. - A user-defined function called
SortArray( )
to sort any array in ascending order. - A user-defined function called
Searcharray( )
to search an array for a given target. It returns the position of the target if it has been found or returns a message saying target was not found.
Remarks:
- Use the concept of pointer to perform all operations on the array
a[ ]
. - As an example use the following array
a[ ] ={ 3,2,8,4,1,6}
Elements of the arraya[ ]
should be entered via the keyboard and passed via the function main() to the user-defined function setarray(). - As a target to be searched in the array use both targets: 8 and 5.
- All outputs must be performed within the main function and NOT via any user-defined function.