Advertisement
Guest User

403-PostScript

a guest
Apr 16th, 2020
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.44 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. char sheet[60][60];
  4. bool isValid(int x, int y){
  5.     return x>=0 && x<60 && y>=0 && y<60;
  6. }
  7. void writeC1LetterAt(int x, int y, char letter){
  8.     if(letter!=' ') sheet[x][y]=letter;
  9. }
  10. void writeC5LetterAt(int x, int y, char letter[5][7]){
  11.     for(int i=0; i<5; i++){
  12.         for(int j=0; j<6; j++){
  13.             if(isValid(x+i, y+j) && letter[i][j]!='.'){
  14.                 sheet[x+i][y+j]=letter[i][j];
  15.             }
  16.         }
  17.     }
  18. }
  19. void writeC5Letter(char c, int x, int y){
  20.     if(c=='A'){
  21.         char letter[5][7]={
  22.         ".***..",
  23.         "*...*.",
  24.         "*****.",
  25.         "*...*.",
  26.         "*...*."
  27.         };
  28.         writeC5LetterAt(x, y, letter);
  29.     }
  30.     else if(c=='B'){
  31.         char letter[5][7]={
  32.         "****..",
  33.         "*...*.",
  34.         "****..",
  35.         "*...*.",
  36.         "****.."
  37.         };
  38.         writeC5LetterAt(x, y, letter);
  39.     }
  40.     else if(c=='C'){
  41.         char letter[5][7]={
  42.         ".****.",
  43.         "*...*.",
  44.         "*.....",
  45.         "*.....",
  46.         ".****."
  47.         };
  48.         writeC5LetterAt(x, y, letter);
  49.     }
  50.     else if(c=='D'){
  51.         char letter[5][7]={
  52.         "****..",
  53.         "*...*.",
  54.         "*...*.",
  55.         "*...*.",
  56.         "****.."
  57.         };
  58.         writeC5LetterAt(x, y, letter);
  59.     }
  60.     else if(c=='E'){
  61.         char letter[5][7]={
  62.         "*****.",
  63.         "*.....",
  64.         "***...",
  65.         "*.....",
  66.         "*****."
  67.         };
  68.         writeC5LetterAt(x, y, letter);
  69.     }
  70.     else if(c=='F'){
  71.         char letter[5][7]={
  72.         "*****.",
  73.         "*.....",
  74.         "***...",
  75.         "*.....",
  76.         "*....."
  77.         };
  78.         writeC5LetterAt(x, y, letter);
  79.     }
  80.     else if(c=='G'){
  81.         char letter[5][7]={
  82.         ".****.",
  83.         "*.....",
  84.         "*..**.",
  85.         "*...*.",
  86.         ".***.."
  87.         };
  88.         writeC5LetterAt(x, y, letter);
  89.     }
  90.     else if(c=='H'){
  91.         char letter[5][7]={
  92.         "*...*.",
  93.         "*...*.",
  94.         "*****.",
  95.         "*...*.",
  96.         "*...*."
  97.         };
  98.         writeC5LetterAt(x, y, letter);
  99.     }
  100.     else if(c=='I'){
  101.         char letter[5][7]={
  102.         "*****.",
  103.         "..*...",
  104.         "..*...",
  105.         "..*...",
  106.         "*****."
  107.         };
  108.         writeC5LetterAt(x, y, letter);
  109.     }
  110.     else if(c=='J'){
  111.         char letter[5][7]={
  112.         "..***.",
  113.         "...*..",
  114.         "...*..",
  115.         "*..*..",
  116.         ".**..."
  117.         };
  118.         writeC5LetterAt(x, y, letter);
  119.     }
  120.     else if(c=='K'){
  121.         char letter[5][7]={
  122.         "*...*.",
  123.         "*..*..",
  124.         "***...",
  125.         "*..*..",
  126.         "*...*."
  127.         };
  128.         writeC5LetterAt(x, y, letter);
  129.     }
  130.     else if(c=='L'){
  131.         char letter[5][7]={
  132.         "*.....",
  133.         "*.....",
  134.         "*.....",
  135.         "*.....",
  136.         "*****."
  137.         };
  138.         writeC5LetterAt(x, y, letter);
  139.     }
  140.     else if(c=='M'){
  141.         char letter[5][7]={
  142.         "*...*.",
  143.         "**.**.",
  144.         "*.*.*.",
  145.         "*...*.",
  146.         "*...*."
  147.         };
  148.         writeC5LetterAt(x, y, letter);
  149.     }
  150.     else if(c=='N'){
  151.         char letter[5][7]={
  152.         "*...*.",
  153.         "**..*.",
  154.         "*.*.*.",
  155.         "*..**.",
  156.         "*...*."
  157.         };
  158.         writeC5LetterAt(x, y, letter);
  159.     }
  160.     else if(c=='O'){
  161.         char letter[5][7]={
  162.         ".***..",
  163.         "*...*.",
  164.         "*...*.",
  165.         "*...*.",
  166.         ".***.."
  167.         };
  168.         writeC5LetterAt(x, y, letter);
  169.     }
  170.     else if(c=='P'){
  171.         char letter[5][7]={
  172.         "****..",
  173.         "*...*.",
  174.         "****..",
  175.         "*.....",
  176.         "*....."
  177.         };
  178.         writeC5LetterAt(x, y, letter);
  179.     }
  180.     else if(c=='Q'){
  181.         char letter[5][7]={
  182.         ".***..",
  183.         "*...*.",
  184.         "*...*.",
  185.         "*..**.",
  186.         ".****."
  187.         };
  188.         writeC5LetterAt(x, y, letter);
  189.     }
  190.     else if(c=='R'){
  191.         char letter[5][7]={
  192.         "****..",
  193.         "*...*.",
  194.         "****..",
  195.         "*..*..",
  196.         "*...*."
  197.         };
  198.         writeC5LetterAt(x, y, letter);
  199.     }
  200.     else if(c=='S'){
  201.         char letter[5][7]={
  202.         ".****.",
  203.         "*.....",
  204.         ".***..",
  205.         "....*.",
  206.         "****.."
  207.         };
  208.         writeC5LetterAt(x, y, letter);
  209.     }
  210.     else if(c=='T'){
  211.         char letter[5][7]={
  212.         "*****.",
  213.         "*.*.*.",
  214.         "..*...",
  215.         "..*...",
  216.         ".***.."
  217.         };
  218.         writeC5LetterAt(x, y, letter);
  219.     }
  220.     else if(c=='U'){
  221.         char letter[5][7]={
  222.         "*...*.",
  223.         "*...*.",
  224.         "*...*.",
  225.         "*...*.",
  226.         ".***.."
  227.         };
  228.         writeC5LetterAt(x, y, letter);
  229.     }
  230.     else if(c=='V'){
  231.         char letter[5][7]={
  232.         "*...*.",
  233.         "*...*.",
  234.         ".*.*..",
  235.         ".*.*..",
  236.         "..*..."
  237.         };
  238.         writeC5LetterAt(x, y, letter);
  239.     }
  240.     else if(c=='W'){
  241.         char letter[5][7]={
  242.         "*...*.",
  243.         "*...*.",
  244.         "*.*.*.",
  245.         "**.**.",
  246.         "*...*."
  247.         };
  248.         writeC5LetterAt(x, y, letter);
  249.     }
  250.     else if(c=='X'){
  251.         char letter[5][7]={
  252.         "*...*.",
  253.         ".*.*..",
  254.         "..*...",
  255.         ".*.*..",
  256.         "*...*."
  257.         };
  258.         writeC5LetterAt(x, y, letter);
  259.     }
  260.     else if(c=='Y'){
  261.         char letter[5][7]={
  262.         "*...*.",
  263.         ".*.*..",
  264.         "..*...",
  265.         "..*...",
  266.         "..*..."
  267.         };
  268.         writeC5LetterAt(x, y, letter);
  269.     }
  270.     else if(c=='Z'){
  271.         char letter[5][7]={
  272.         "*****.",
  273.         "...*..",
  274.         "..*...",
  275.         ".*....",
  276.         "*****."
  277.         };
  278.         writeC5LetterAt(x, y, letter);
  279.     }
  280.     else if(c=='.'){
  281.         char letter[5][7]={
  282.         "......",
  283.         "......",
  284.         "......",
  285.         "......",
  286.         "......"
  287.         };
  288.         writeC5LetterAt(x, y, letter);
  289.     }
  290.  
  291. }
  292. void writeC1From(string str, int x, int y){
  293.     //cout << "Writting: *" << str << "* on row " << x+1 << "; and col " << y+1 << "\n";
  294.     int strPos=0;
  295.     int yPos=y;
  296.     while(strPos<str.size() && yPos<60){
  297.         writeC1LetterAt(x, yPos, str[strPos]);
  298.         strPos++;
  299.         yPos++;
  300.     }
  301. }
  302. void writeC5From(string str, int x, int y){
  303.     int strPos=0;
  304.     int yPos=y;
  305.     while(strPos<str.size() && yPos<60){
  306.         char actChar=str[strPos];
  307.         writeC5Letter(actChar, x, y);
  308.         strPos++;
  309.         y+=6;
  310.     }
  311. }
  312. void writeC1Centered(string str, int x){
  313.     int strPos=str.size()/2;
  314.     int yPos=30;
  315.     while(strPos>0){
  316.         yPos--;
  317.         strPos--;
  318.     }
  319.     while(strPos<str.size() && yPos<60){
  320.         writeC1LetterAt(x, yPos, str[strPos]);
  321.         strPos++;
  322.         yPos++;
  323.     }
  324. }
  325. void writeC5Centered(string str, int x){
  326.     int strPos=str.size()/2;
  327.     int yPos= str.size()%2!=0 ? 27 : 30;
  328.     while(strPos>0){
  329.         yPos-=6;
  330.         strPos--;
  331.     }
  332.     while(strPos<str.size() && yPos<60){
  333.         writeC5Letter(str[strPos], x, yPos);
  334.         strPos++;
  335.         yPos+=6;
  336.     }
  337. }
  338. void writeC1Right(string str, int x){
  339.     int strPos=str.size()-1;
  340.     int yPos=59;
  341.     while(strPos>=0){
  342.         writeC1LetterAt(x, yPos, str[strPos]);
  343.         strPos--;
  344.         yPos--;
  345.     }
  346. }
  347. void writeC5Right(string str, int x){
  348.     int strPos=str.size()-1;
  349.     int yPos=54;
  350.     while(strPos>=0){
  351.         char actChar=str[strPos];
  352.         writeC5Letter(actChar, x, yPos);
  353.         strPos--;
  354.         yPos-=6;
  355.     }
  356. }
  357. void cleanSheet(){
  358.     for(int i=0; i<60; i++){
  359.         for(int j=0; j<60; j++){
  360.             sheet[i][j]='.';
  361.         }
  362.     }
  363. }
  364. void printSheet(){
  365.     for(int i=0; i<60; i++){
  366.         for(int j=0; j<60; j++){
  367.             cout << sheet[i][j];
  368.         }
  369.         cout << "\n";
  370.     }
  371.     cout << "\n";
  372.     for(int i=0; i<60; i++){
  373.         cout << "-";
  374.     }
  375.     cout << "\n\n";
  376. }
  377. int main(){
  378.     //freopen("in.txt", "r", stdin);
  379.     //freopen("out.txt", "w", stdout);
  380.     //ios_base::sync_with_stdio(false);
  381.     //cin.tie(NULL);
  382.     string op;
  383.     cleanSheet();
  384.     while(cin >> op){
  385.         string str, font;
  386.         int row, col;
  387.         //cout << "OP: " << op << "*\n";
  388.         if(op==".EOP"){
  389.             printSheet();
  390.             cleanSheet();
  391.             continue;
  392.         }
  393.         cin >> font >> row;
  394.         row--;
  395.         if(op==".P"){
  396.             cin >> col;
  397.             col--;
  398.         }
  399.         getline(cin, str);
  400.         str=str.substr(2, str.size()-3);
  401.         //cout << "OP: " << op << "; Font: " << font << "\n";
  402.         //cout << "Row: " << row << "; Col: " << col << "\n";
  403.         //cout << "*" << str << "*\n";
  404.         if(op==".P"){
  405.             if(font=="C1"){
  406.                 writeC1From(str, row, col);
  407.             }
  408.             if(font=="C5"){
  409.                 writeC5From(str, row, col);
  410.             }
  411.         }
  412.         if(op==".L"){
  413.             if(font=="C1"){
  414.                writeC1From(str, row, 0);
  415.             }
  416.             if(font=="C5"){
  417.                 writeC5From(str, row, 0);
  418.             }
  419.         }
  420.         if(op==".R"){
  421.             if(font=="C1"){
  422.                writeC1Right(str, row);
  423.             }
  424.             if(font=="C5"){
  425.                 writeC5Right(str, row);
  426.             }
  427.         }
  428.         if(op==".C"){
  429.             if(font=="C1"){
  430.                writeC1Centered(str, row);
  431.             }
  432.             if(font=="C5"){
  433.                 writeC5Centered(str, row);
  434.             }
  435.         }
  436.     }
  437.     return 0;
  438. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement