Question: Please help review my Multi dimensional Array! Easy question. Basically I'm trying to create a matrix 5 by 5. Also each letter cant be repeated
Please help review my Multi dimensional Array! Easy question.
Basically I'm trying to create a matrix 5 by 5. Also each letter cant be repeated more than once in matrix and it cant use letter 'Z'.
I don't know to get rid of duplicates, no using function please!
Oh and I was wondering how I should approach encrypting the string matrixinput? How I was approaching it wasn't working.
No function used for that also! I'd rather not use any functions.
Here is my code:
#include
int main(){ ifstream infile; infile.open("machineproblem5"); const int numCol = 5; string alaphabet="ABCDEFGHIJKLMNOPQRSTUVWXY"; char arr[5][5]; string firstline; char inputString[256]; char inputChar; infile>>firstline; infile>>inputChar; infile.getline(inputString,256); string matrixinput=(firstline+alaphabet); for(int x=0;x if(inputChar=='E'){ cout<< "encrypts to: "< This is the read in file: Happiness D EVDEUOA XC GCERVLEWQ, FESS BC EUV OCWWAOX XLC HNUVRAV VCWWERS E hello there D HAWWC XHARA E attack at dawn D IAAX IA NUVAR HEIIARSIMXH GRMVBA E the meeting is in san francisco D XHMS MUPCRIEXMCU MS AUORYFXAV NSMUB XHA QAYLCRV HEFFMUASS D XHA EUSLAR XC XHA PMRSX KNASXMCU CU XHA PMUEW IEY GA XRNA CR MX IEY GA PEWSA E the answer to the first question on the final may be true or it may be false D OCUBREXNWEXMCUS YCN IEVA MX XHRCNBH XHMS IEOHMUA FRCGWAI E advance to boardwalk, pass go and collect two hundred dollars E make my day E zorro is back (in town) E you ain't nothing but a hound dog E one day a computer will weigh less than a ton --- popular mechanics 1948 E no computer will ever need more than 640k of memory -- bill gates in the mid eighties D YCN EMUX UCXHMUB GNX E HCNUV VCB How it should look output wise: https://imgur.com/a/H2Cyj keyword is HAPPINESS 0 1 2 3 4 0| H | A | P | I | N | 1| E | S | B | C | D | 2| F | G | J | K | L | 3| M | O | Q | R | T | 4| U | V | W | X | Y | **************************************** EVDEUOA XC GCERVLEWQ, FESS BC EUV OCWWAOX XLC HNUVRAV VCWWERS decrypts to: advance to boardwalk, pass go and collect two hundred dollars **************************************** hello there encrypts to HAWWC XHARA **************************************** HAWWC XHARA decrypts to: hello there **************************************** attack at dawn encrypts to EXXEOQ EX VELU ****************************************
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
