Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

s o l s s e this cypher can be read going from o u t t o l top to bottom,and the

ID: 3625232 • Letter: S

Question


s o l s s e                            this cypher can be read going from
o u t  t o l                               top to bottom,and then to top of
l  n h e f d                                     next line.
v v e  r t e
e e m i h r
t i  y  e e s

Cypher-text: “solsse outtol lnhefd vverte eemihr tiyees”
Plain-text: “solve to unveil the mysteries of the elders”

User input string will be always 36 characters).[6*6 matrix]Encrypted or decrypted output (i.e. either plaintext or cyphertext) as per user’s choice should be displayed.
Plz dont use pointers!!!







Explanation / Answer

please rate - thanks

sorry, couldn't figure out where to put spaces when ouputting plain text

#include <iostream>
using namespace std;
void fromPlain(char[][6]);
void toPlain(char[][6]);
void enterPlainText(char[][6]);
void enterEncryptedText(char[][6]);
void print(char[][6]);
int menu();
int main()
{char mat[6][6];
int choice;
bool first=true;
choice=menu();
while(choice!=5)
    {if(first&&(choice==3||choice==4))
         cout<<"must enter data before can change it ";   
     else if(choice==1)
          {enterPlainText(mat);
          print(mat);
          first=false;
          }
    else if(choice==2)
          {enterEncryptedText(mat);
          print(mat);
          first=false;
          }
    else if(choice==3)
         fromPlain(mat);
    else
         toPlain(mat);
    choice=menu();
    }
return 0;
}
void print(char mat[][6])
{int i,j;
cout<<" The Matrix ";
for(i=0;i<6;i++)
     {for(j=0;j<6;j++)
          cout<<mat[i][j]<<" ";
     cout<<endl;
     }
cout<<endl;
}

void enterPlainText(char mat[][6])
{int i,j;
cout<<"Enter plain text must be 36 characters excluding blanks: ";
for(i=0;i<6;i++)
   for(j=0;j<6;j++)
   do{
     cin>>mat[j][i];
     }while(mat[j][i]==' ');
}
void enterEncryptedText(char mat[][6])
{int i,j;
cout<<"Enter encrypted text must be 36 characters excluding blanks: ";
for(i=0;i<6;i++)
   for(j=0;j<6;j++)
     do{
       cin>>mat[i][j];
     }while(mat[i][j]==' ');
}
int menu()
{
char choice='0';
while(choice<'1'||choice>'5')
    {cout<<"what would you like to do? ";
    cout<<"1 enter plain text ";
    cout<<"2 enter encrypted text ";
    cout<<"3 convert plain text to encrypted text ";
    cout<<"4 convert encrypted text to plain text ";
    cout<<"5 exit ";
    cin>>choice;
    if(choice<'1'||choice>'5')
         cout<<"Invalid choice ";
    }
return choice-'0';
}
void fromPlain(char mat[][6])
{int i,j;
cout<<endl;
for(i=0;i<6;i++)
    {for(j=0;j<6;j++)
         cout<<mat[i][j];
    cout<<" ";
    }
cout<<endl<<endl;
}

void toPlain(char mat[][6])
{int i,j;
cout<<endl;
for(i=0;i<6;i++)
    for(j=0;j<6;j++)
         cout<<mat[j][i];
cout<<endl<<endl;
}