Zebra0.com

MCC++ Project: Strings

C++ Project: Strings

Strings

You are to write either the cryptogram or anagram program.For either choice, the shuffle code must be a function that receives a string and returns a string.

Anagram:

You are to write a program that inputs a word and displays 5 random anagrams.

The algorithm is as follows:

  1. Read in the word and convert ot oupper case.
  2. Split the word into an array of characters.
  3. Shuffle the array and create a string of the letters and display it.
  4. Loop to display 5 different anagrams.

Example:

Word is world: output: DOWLR, RODWL, WDLOR, LOWDR, RWOLD

Cryptogram:

You are to write a program that inputs a sentence and turns it into a cryptogram.

The algorithm is as follows:

Split the alphabet into an array of characters.

Shuffle the alphabet:

Example:

alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

code="EWMDAXLVTOPGCNJKQZSIUHBFYR"

sentence="I THINK THEREFORE I AM."

Loop through the letters in the sentence. For each letter find the position of the letter and replace with the letter in the same position of the code.

Shuffle Algorithm:


This web site, and all pages therein, are the sole property and responsibility of Zebra0.com.
It is not endorsed, sponsored, or provided by or on behalf of Montgomery College.