// PUNCH3.CPP // Micheal H. McCabe // Retrochallenge 2022/10 // October 3, 2022 #include #include using namespace std; #define ERROR 9999 int o29_code[] = { ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* control */ ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* chars */ ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* control */ ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR,ERROR, /* chars */ 00000,02202,00006,00102,02102,01042,04000,00022, /* !"#$%&' */ 04022,02022,02042,04012,01102,02000,04102,01400, /* ()*+,-./ */ 01000,00400,00200,00100,00040,00020,00010,00004, /* 01234567 */ 00002,00001,00202,02012,04042,00012,01012,01006, /* 89:;<=>? */ 00042,04400,04200,04100,04040,04020,04010,04004, /* @ABCDEFG */ 04002,04001,02400,02200,02100,02040,02020,02010, /* HIJKLMNO */ 02004,02002,02001,01200,01100,01040,01020,01010, /* PQRSTUVW */ 01004,01002,01001,04202,02006,01202,04006,01022, /* XYZ[\]^_ */ ERROR,04400,04200,04100,04040,04020,04010,04004, /* `abcdefg */ 04002,04001,02400,02200,02100,02040,02020,02010, /* hijklmno */ 02004,02002,02001,01200,01100,01040,01020,01010, /* pqrstuvw */ 01004,01002,01001,ERROR,ERROR,ERROR,ERROR,ERROR /* xyz{|}~ */ }; bool card [80][12]; void ConvertAscii(int Value,int i) { if (Value>=0 && Value<4096) { int m=2048; for (int j=11; j>=0; j--) { int bit=Value/m; Value=Value-bit*m; if (bit==1) { card[i+1][j+1] = true; } if (bit==0) { card[i+1][j+1] = false; } m=m/2; } } return; } void PrintCard(string ascii) { cout << " /================================================================================+" << endl; cout << " / " << ascii; for (int k=(80-ascii.length()); k>0; k--) { cout << " "; } cout << "|" << endl; for (int row=12; row > 0; row--) { cout << " | "; for(int column=1; column<81; column++) { if (card[column][row]) { cout << "#"; } else cout << " "; } cout << "|" << endl; } cout << " +==================================================================================+" << endl; return; } int main() { string ascii; cout << "Generate an ASCII Art Hollerith Card" << endl; cout << "Micheal H. McCabe" << endl; cout << "October 3, 2022" << endl; cout << endl; cout << "Please enter a line of ASCII text for conversion to Hollerith Code." << endl << endl; cout << ">"; getline (cin,ascii); cout << endl; int len = ascii.length(); if (len>80) ascii=ascii.substr(0,79); for (int i=0; i