SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Downloaden Sie, um offline zu lesen
Help with this substitution program, line 3 of the output is different than it should be and I
can't find the reaso why. Here's the code, the input file, and the output file.
#include "cipher.h"
/* Cheshire smile implementation.
It only contains the cipher alphabet
*/
struct Cipher::CipherCheshire {
string cipher_alpha;
};
/* This function checks the cipher alphabet
to make sure it's valid
*/
bool is_valid_alpha(string alpha);
// -------------------------------------------------------
// Cipher implementation
/* Default constructor
This will actually not encrypt the input text
because it's using the unscrambled alphabet
*/
Cipher::Cipher()
{
// TODO: Implement this default constructor
smile = new CipherCheshire();
smile->cipher_alpha = "zyxwvutsrqponmlkjihgfedcba";
}
/* This constructor initiates the object with a
input cipher key
*/
Cipher::Cipher(string cipher_alpha)
{
// TODO: Implement this constructor
smile - new CipherCheshire();
if (is_valid_alpha(cipher_alpha)) {
smile->cipher_alpha = cipher_alpha;
} else {
cout << "Invalid alpha" << endl;
exit(EXIT_FAILURE);
}
}
/* Destructor
*/
Cipher::~Cipher()
{
// TODO: Implement this constructor
delete(smile);
}
/* This member function encrypts the input text
using the intialized cipher key
*/
string Cipher::encrypt(string raw)
{
cout << "Encrypting...";
string retStr = "";
char ch, tmp;
int pos;
int i;
int size = raw.length();
// TODO: Finish this function
for (i = 0; i < size; i++) {
tmp = ' ';
ch = raw.at(i);
if (ch != ' ') {
por = find_pos(smile->cipher_alpha, ch)
if (ch >= 65 && ch <= 90) {
tmp = 65 + pos;
} else {
tmp = 97 + pos;
}
}
retStr += tmp;
}
cout << "Done" << endl;
return retStr;
}
/* This member function decrypts the input text
using the intialized cipher key
*/
string Cipher::decrypt(string enc)
{
string retStr = "";
char ch, tmp;
int pos;
int i;
int size = enc.length();
cout << "Decrypting...";
// TODO: Finish this function
for (i = 0; i < size; i++) {
tmp = ' ';
ch = enc.at(i);
if (ch != ' ') {
pos = find_pos(smile->cipher_alpha, ch);
if (ch >= 65 && ch <= 90) {
tmp = 65 + pos;
} else {
tmp = 97 + pos;
}
}
retStr += tmp;
}
cout << "Done" << endl;
return retStr;
}
// -------------------------------------------------------
// Helper functions
/* Find the character c's position in the cipher alphabet/key
*/
unsigned int find_pos(string alpha, char c)
{
unsigned int pos = 0;
int i;
int size = alpha.length();
// TODO: You will likely need this function. Finish it.
char ch = tolower(c);
for (i = 0; i < size; i++) {
if (ch == alpha.at(i)) {
por = i;
break;
}
}
return pos;
}
/* Make sure the cipher alphabet is valid -
a) it must contain every letter in the alphabet
b) it must contain only one of each letter
c) it must be all lower case letters
ALL of the above conditions must be met for the text to be a valid
cipher alphabet.
*/
bool is_valid_alpha(string alpha)
{
bool is_valid = true;
if(alpha.size() != ALPHABET_SIZE) {
is_valid = false;
} else {
unsigned int letter_exists[ALPHABET_SIZE];
for(unsigned int i = 0; i < ALPHABET_SIZE; i++) {
letter_exists[i] = 0;
}
for(unsigned int i = 0; i < alpha.size(); i++) {
char c = alpha[i];
if(!((c >= 'a') && (c <= 'z'))) {
is_valid = false;
} else {
letter_exists[(c - 'a')]++;
}
}
for(unsigned int i = 0; i < ALPHABET_SIZE; i++) {
if(letter_exists[i] != 1) {
is_valid = false;
}
}
}
return is_valid;
}
INPUT:
EXPECTED OUTPUT:
CURRENT OUTPUT:
zyxwvutsrqponmlkj ihgfedcba Sometimes it is the people no one can imagine anything of who
do the things no one can imagine Hlnvgrnvh rg rh gsv kvlkov ml lmv Xzm rnztrmv zmbgsrmt lu
dsl wl gsv gsrmth ml lmv Xzm rnztrmv Sometimes it is the people no one can imagine anything
of who do the things no one can imagine Sometimes it is the people no one can imagine anything
of who do the things no one can imagine Sometimes it is the people no one can imagine anything
of who do the things no one can imagine Hlnvgrnvh rg rh gsv kvlkov ml lmv xzm rnztrmv
zmbgsrmt lu dsl wl gsv gsrmth ml lmv xzm rnztrmv Sometimes it is the people no one can
imagine anything of who do the things no one can imagine Hlnvgrnvh rg rh gsv kvlkov ml lmv
Xzm rnztrmv zmbgsrmt lu dsl wl gsv gsrmth ml lmv Xzm rnztrmv Sometimes it is the people no
one can imagine anything of who do the things no one can imagine

Weitere ähnliche Inhalte

Ähnlich wie Help with this substitution program- line 3 of the output is different.pdf

Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docx
MARRY7
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
rozakashif85
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdf
contact32
 
a) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdfa) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdf
anuradhasilks
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
Srikanth
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
Srikanth
 

Ähnlich wie Help with this substitution program- line 3 of the output is different.pdf (20)

Embedding perl
Embedding perlEmbedding perl
Embedding perl
 
Asssignment2
Asssignment2 Asssignment2
Asssignment2
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docx
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
 
pointers 1
pointers 1pointers 1
pointers 1
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdf
 
a) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdfa) In the code, board is initialized by reading an input file. But y.pdf
a) In the code, board is initialized by reading an input file. But y.pdf
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
Yg byev2e
Yg byev2eYg byev2e
Yg byev2e
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Basic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersBasic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmers
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
 

Mehr von gaurav444u

Header #include -string- #include -vector- #include -iostream- using.pdf
Header #include -string- #include -vector- #include -iostream-   using.pdfHeader #include -string- #include -vector- #include -iostream-   using.pdf
Header #include -string- #include -vector- #include -iostream- using.pdf
gaurav444u
 
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdfHarvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
gaurav444u
 

Mehr von gaurav444u (20)

Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdfHealth Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
Health Care Unions Find a Voice as the Pandemic Rages - The New York T.pdf
 
Health - Related Questions 1- What three pieces of information are gat.pdf
Health - Related Questions 1- What three pieces of information are gat.pdfHealth - Related Questions 1- What three pieces of information are gat.pdf
Health - Related Questions 1- What three pieces of information are gat.pdf
 
Health Information Technology (HIT) as Electronic Health Record (EHR).pdf
Health Information Technology (HIT) as Electronic Health Record (EHR).pdfHealth Information Technology (HIT) as Electronic Health Record (EHR).pdf
Health Information Technology (HIT) as Electronic Health Record (EHR).pdf
 
Headlands Limited has the following information available regarding it.pdf
Headlands Limited has the following information available regarding it.pdfHeadlands Limited has the following information available regarding it.pdf
Headlands Limited has the following information available regarding it.pdf
 
Header #include -string- #include -vector- #include -iostream- using.pdf
Header #include -string- #include -vector- #include -iostream-   using.pdfHeader #include -string- #include -vector- #include -iostream-   using.pdf
Header #include -string- #include -vector- #include -iostream- using.pdf
 
he method by which glucose is transported into a cell depends on the m.pdf
he method by which glucose is transported into a cell depends on the m.pdfhe method by which glucose is transported into a cell depends on the m.pdf
he method by which glucose is transported into a cell depends on the m.pdf
 
he City Council of Inman Village approved a budget with estimated reve.pdf
he City Council of Inman Village approved a budget with estimated reve.pdfhe City Council of Inman Village approved a budget with estimated reve.pdf
he City Council of Inman Village approved a budget with estimated reve.pdf
 
he department has expanded telehealth and device-monitoring services-.pdf
he department has expanded telehealth and device-monitoring services-.pdfhe department has expanded telehealth and device-monitoring services-.pdf
he department has expanded telehealth and device-monitoring services-.pdf
 
he evolution of eukaryotic cells most likely occurred in many steps- O.pdf
he evolution of eukaryotic cells most likely occurred in many steps- O.pdfhe evolution of eukaryotic cells most likely occurred in many steps- O.pdf
he evolution of eukaryotic cells most likely occurred in many steps- O.pdf
 
Having passed your board exam- you are now qualified to work in the pa.pdf
Having passed your board exam- you are now qualified to work in the pa.pdfHaving passed your board exam- you are now qualified to work in the pa.pdf
Having passed your board exam- you are now qualified to work in the pa.pdf
 
Having been lost in the desert for 2 days without water- Marion is bad.pdf
Having been lost in the desert for 2 days without water- Marion is bad.pdfHaving been lost in the desert for 2 days without water- Marion is bad.pdf
Having been lost in the desert for 2 days without water- Marion is bad.pdf
 
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdfHarvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
Harvard Case Study- Humana's Bold Goal- 20 Percent Healthier by 2020 -.pdf
 
Harry climbed a ladder to trim some trees- While bending too fast- he.pdf
Harry climbed a ladder to trim some trees- While bending too fast- he.pdfHarry climbed a ladder to trim some trees- While bending too fast- he.pdf
Harry climbed a ladder to trim some trees- While bending too fast- he.pdf
 
HELP- Add button wont work-- i would click on the button and that page.pdf
HELP- Add button wont work-- i would click on the button and that page.pdfHELP- Add button wont work-- i would click on the button and that page.pdf
HELP- Add button wont work-- i would click on the button and that page.pdf
 
help The following information pertains to Ming Corp- at January 1- Ye.pdf
help The following information pertains to Ming Corp- at January 1- Ye.pdfhelp The following information pertains to Ming Corp- at January 1- Ye.pdf
help The following information pertains to Ming Corp- at January 1- Ye.pdf
 
Help Tina identify her strengths- weaknesses- the opportunities presen.pdf
Help Tina identify her strengths- weaknesses- the opportunities presen.pdfHelp Tina identify her strengths- weaknesses- the opportunities presen.pdf
Help Tina identify her strengths- weaknesses- the opportunities presen.pdf
 
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdfHarriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
Harriet Quarterly wants a 14- return on the $15000 of assets she has i.pdf
 
Harriet is described as someone who -was unusual in her ability to coo.pdf
Harriet is described as someone who -was unusual in her ability to coo.pdfHarriet is described as someone who -was unusual in her ability to coo.pdf
Harriet is described as someone who -was unusual in her ability to coo.pdf
 
help please- thank you! i need to know the Virginia Department of Educ.pdf
help please- thank you! i need to know the Virginia Department of Educ.pdfhelp please- thank you! i need to know the Virginia Department of Educ.pdf
help please- thank you! i need to know the Virginia Department of Educ.pdf
 
Help please! 1- You are wanting to know how many sloths are in a pop.pdf
Help please!   1- You are wanting to know how many sloths are in a pop.pdfHelp please!   1- You are wanting to know how many sloths are in a pop.pdf
Help please! 1- You are wanting to know how many sloths are in a pop.pdf
 

Kürzlich hochgeladen

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Kürzlich hochgeladen (20)

Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Help with this substitution program- line 3 of the output is different.pdf

  • 1. Help with this substitution program, line 3 of the output is different than it should be and I can't find the reaso why. Here's the code, the input file, and the output file. #include "cipher.h" /* Cheshire smile implementation. It only contains the cipher alphabet */ struct Cipher::CipherCheshire { string cipher_alpha; }; /* This function checks the cipher alphabet to make sure it's valid */ bool is_valid_alpha(string alpha); // ------------------------------------------------------- // Cipher implementation /* Default constructor This will actually not encrypt the input text because it's using the unscrambled alphabet */ Cipher::Cipher() { // TODO: Implement this default constructor smile = new CipherCheshire(); smile->cipher_alpha = "zyxwvutsrqponmlkjihgfedcba"; } /* This constructor initiates the object with a input cipher key */ Cipher::Cipher(string cipher_alpha) { // TODO: Implement this constructor smile - new CipherCheshire(); if (is_valid_alpha(cipher_alpha)) { smile->cipher_alpha = cipher_alpha; } else { cout << "Invalid alpha" << endl; exit(EXIT_FAILURE); } }
  • 2. /* Destructor */ Cipher::~Cipher() { // TODO: Implement this constructor delete(smile); } /* This member function encrypts the input text using the intialized cipher key */ string Cipher::encrypt(string raw) { cout << "Encrypting..."; string retStr = ""; char ch, tmp; int pos; int i; int size = raw.length(); // TODO: Finish this function for (i = 0; i < size; i++) { tmp = ' '; ch = raw.at(i); if (ch != ' ') { por = find_pos(smile->cipher_alpha, ch) if (ch >= 65 && ch <= 90) { tmp = 65 + pos; } else { tmp = 97 + pos; } } retStr += tmp; } cout << "Done" << endl; return retStr; } /* This member function decrypts the input text using the intialized cipher key */ string Cipher::decrypt(string enc) { string retStr = "";
  • 3. char ch, tmp; int pos; int i; int size = enc.length(); cout << "Decrypting..."; // TODO: Finish this function for (i = 0; i < size; i++) { tmp = ' '; ch = enc.at(i); if (ch != ' ') { pos = find_pos(smile->cipher_alpha, ch); if (ch >= 65 && ch <= 90) { tmp = 65 + pos; } else { tmp = 97 + pos; } } retStr += tmp; } cout << "Done" << endl; return retStr; } // ------------------------------------------------------- // Helper functions /* Find the character c's position in the cipher alphabet/key */ unsigned int find_pos(string alpha, char c) { unsigned int pos = 0; int i; int size = alpha.length(); // TODO: You will likely need this function. Finish it. char ch = tolower(c); for (i = 0; i < size; i++) { if (ch == alpha.at(i)) { por = i; break; } }
  • 4. return pos; } /* Make sure the cipher alphabet is valid - a) it must contain every letter in the alphabet b) it must contain only one of each letter c) it must be all lower case letters ALL of the above conditions must be met for the text to be a valid cipher alphabet. */ bool is_valid_alpha(string alpha) { bool is_valid = true; if(alpha.size() != ALPHABET_SIZE) { is_valid = false; } else { unsigned int letter_exists[ALPHABET_SIZE]; for(unsigned int i = 0; i < ALPHABET_SIZE; i++) { letter_exists[i] = 0; } for(unsigned int i = 0; i < alpha.size(); i++) { char c = alpha[i]; if(!((c >= 'a') && (c <= 'z'))) { is_valid = false; } else { letter_exists[(c - 'a')]++; } } for(unsigned int i = 0; i < ALPHABET_SIZE; i++) { if(letter_exists[i] != 1) { is_valid = false; } } } return is_valid; } INPUT: EXPECTED OUTPUT: CURRENT OUTPUT: zyxwvutsrqponmlkj ihgfedcba Sometimes it is the people no one can imagine anything of who do the things no one can imagine Hlnvgrnvh rg rh gsv kvlkov ml lmv Xzm rnztrmv zmbgsrmt lu dsl wl gsv gsrmth ml lmv Xzm rnztrmv Sometimes it is the people no one can imagine anything
  • 5. of who do the things no one can imagine Sometimes it is the people no one can imagine anything of who do the things no one can imagine Sometimes it is the people no one can imagine anything of who do the things no one can imagine Hlnvgrnvh rg rh gsv kvlkov ml lmv xzm rnztrmv zmbgsrmt lu dsl wl gsv gsrmth ml lmv xzm rnztrmv Sometimes it is the people no one can imagine anything of who do the things no one can imagine Hlnvgrnvh rg rh gsv kvlkov ml lmv Xzm rnztrmv zmbgsrmt lu dsl wl gsv gsrmth ml lmv Xzm rnztrmv Sometimes it is the people no one can imagine anything of who do the things no one can imagine