(Solved) : Include Include Using Namespace Std Int Main Int Choicewidthlen String Str Str1 Str1 Used Q43924666 . . .


![aryli) = new char[width];//declaring a two dimension character array with size len x width int k=0; %3! for(int į = 0; į< len](https://media.cheggcdn.com/media/f4d/f4d170c8-2c2f-49a8-8622-217722fdf224/phpbxJuPU.png)

#include<iostream> #include<string> using namespace std; int main() { int choice.width.len; string str,str1=”_”://str1 will be used later to append to message (i.e str) cout<<“Enter the message to Encrypt or Decrypt: “; getlinelcin, str); dof cout<<“nEnter your choice :n1. Encrypt the messagen2. Decrypt the message “;//loop to ensure that the user enters the correct option çin>>choice; if(choice==1) break; if(choice==2) break; if(choice!=1 || choice!=2) cout<<“nPlease enter a valid choice”; łwhile(1); cout<<“nEnter the size of grid width that you want to use for “; if(choice==1) cout<<“encryption “; else cout<“decryption “; while(1) { cin>>width; if(width<=0) { cout<<“nWidth can not be zero or negative. Please enter again “; else break; } while(1) {/this loop is used for padding if(str.size()%width!=0) str.append(str1); else break; } len=str.size()/width; if(choice==1) {//for encrypting the message char** ary = new char*[len); for(int į = 0; į< len; i++) aryli) = new char[width];//declaring a two dimension character array with size len x width int k=0; %3! for(int į = 0; į< len; i+) for(int j= 0; j< width; jtt) { arylijli] = str[k];//entering the string values in array k++; } cout<<“You entered the following message : n”; size t pos = str.find(“_”); cout<<str.substr (0,pos); cout<<“nThe encrypted message is :n”; for(int j = 0; j< width; itt) for(int į = 0; į< len; į+) cout<<arylillil://printing the values stored vertically cout<<“n”; } if(choice==2) { %3D char** ary = new char* [len); for(int į = 0; į <= len; i++) | = new char[width]; int k=0; for(int j = 0; j< width; itt) for(int į = 0; į<= len; i++) { arylijlj] = str[k];//entering the string values to the array vertically k++; } cout<<“You entered the following message : n”<<str; %3D %3D cout<<“nThe decrypted message is :n”; for(int į = 0; į<= len; i++) for(int j = 0; j< width; itt) cout<<arylil lil://printing the values stored in regular method(horizontally) } %3D This C++ program has errors with the encryption and the decryption of the message when the size of grid width that we want to use for is an odd number. As an example, if we have the plaintext “ATTACKATDAWN” and the grid width of 5 and we want to decrypt it: т т This should produce “AKWTANTT_AD_CA_” K PEASE HELP ME TO FIX THE C+ PROGRAM!!! Show transcribed image text #include #include using namespace std; int main() { int choice.width.len; string str,str1=”_”://str1 will be used later to append to message (i.e str) cout
Expert Answer
Answer to #include #include using namespace std; int main() { int choice.width.len; string str,str1=”_”://str1 will be used later …
OR