This repository contains two C++ console-based applications:
- A Paraphrasing Application for rewording text using synonyms.
- A program demonstrating the use of Dynamic Arrays for 2D to 1D data transformations and sorting.
Paraphrasing involves rewording text for simplification or clarity. This application allows users to input a text, which is then paraphrased using a list of synonyms stored in memory.
-
Reading a Synonyms File
- The application reads a file containing words and their synonyms.
- Each synonym is separated by a single white space. Example:
abandon discontinue vacate absent missing unavailable cable wire calculate compute determine measure safety security refuge
- The data is stored in memory using parallel arrays or dynamically allocated arrays of arrays. For example:
Here,
words array synonyms array of arrays 0 abandon 0 ptr0 → discontinue vacate 1 absent 1 ptr1 → missing unavailable 2 cable 2 ptr2 → wire 3 calculate 3 ptr3 → compute determine measure 4 safety 4 ptr4 → security refuge
ptr0
,ptr1
, etc., are dynamically assigned pointers at runtime.
-
User Input Text
- Users provide text input, which is tokenized into words.
-
Word Replacement
- Each word is checked against the synonyms list.
- If a word is found in the synonyms list, it is replaced with one of its synonyms (randomly chosen if multiple synonyms exist).
-
Output
- The application outputs the paraphrased text.
This application demonstrates the creation, manipulation, and sorting of dynamic arrays in C++. It includes the conversion of a 2D dynamic array into a 1D array, sorting the 1D array, and displaying the results.
-
Create a 2D Dynamic Array
- A 2D dynamic array is created in the main function.
- Each row has a different column length, and all values must be positive.
-
Fill the Array
- A function
fillArray
:- Receives the 2D array from the main function.
- Prompts the user to input data for the array.
- Ensures only positive values are accepted.
- A function
-
Convert 2D Array to 1D Array
- A function
twoDimToOneDim
:- Receives the 2D array from the main function.
- Creates a dynamic 1D array large enough to store the contents of the 2D array.
- Returns the address of the dynamically created 1D array to the main function.
- A function
-
Sort the 1D Array
- A function
SortArr
:- Receives the 1D array from the main function.
- Sorts the data in ascending order
- A function
-
Display the Array
- A function
showArr
:- Receives the sorted 1D array.
- Displays its contents on the console without modifying the array.
- A function