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:
- Read in the word and convert ot oupper case.
- Split the word into an array of characters.
- Shuffle the array and create a string of the letters and display it.
- 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:
- Loop through the array from i=0 to i<n
- for each element i generate a random element of the array: r
- swap array[i] and array[r]
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.