Skip to content

mr-taha-saqib/2D-Array-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

C++ Applications: Paraphrasing and Dynamic Array Manipulation

This repository contains two C++ console-based applications:

  1. A Paraphrasing Application for rewording text using synonyms.
  2. A program demonstrating the use of Dynamic Arrays for 2D to 1D data transformations and sorting.

Paraphrasing Application

Overview

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.

Features

  1. 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:
      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
      
      Here, ptr0, ptr1, etc., are dynamically assigned pointers at runtime.
  2. User Input Text

    • Users provide text input, which is tokenized into words.
  3. 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).
  4. Output

    • The application outputs the paraphrased text.

Task 2: Dynamic Array Manipulation

Overview

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.

Features

  1. 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.
  2. 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.
  3. 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.
  4. Sort the 1D Array

    • A function SortArr:
      • Receives the 1D array from the main function.
      • Sorts the data in ascending order
  5. Display the Array

    • A function showArr:
      • Receives the sorted 1D array.
      • Displays its contents on the console without modifying the array.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages