[ create a new paste ] login | about

Link: http://codepad.org/JNijDUgM    [ raw code | output | fork ]

C++, pasted on Dec 21:
#define mCONSOLE 
#ifdef mCONSOLE
#include <iostream>
typedef std::ostream xstream;
#else
#include <fstream>
typedef std::ofstream xstream;
#endif

void mprint(xstream& fp, const char* s, int N, int cx, int cy) {
   int x, y, a, b = cy / 2;
   for(y = 0; y <= cy * N; y++) {
        if(!(y % cy)) {
            for(x = 0; x <= cx * N; x++)
                fp << '-';
            fp << std::endl;
        } else {
            fp << '|';
            a = cx / 2;
            for(int i = 1; i <= cx * N; i++) {
                 if(*s && y == b && i == a) {
                      fp << *s++;
                      a += cx;
                      continue;
                 }
                 fp << ((!(i % cx)) ? '|' : ' ');
            }
            fp << std::endl;
       }
       if(y == b)
          b += cy;
   }
}


int main(void)
{
  mprint(std::cout, "DOGCATFOX", 3, 10, 6);
  return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-------------------------------
|         |         |         |
|         |         |         |
|    D    |    O    |    G    |
|         |         |         |
|         |         |         |
-------------------------------
|         |         |         |
|         |         |         |
|    C    |    A    |    T    |
|         |         |         |
|         |         |         |
-------------------------------
|         |         |         |
|         |         |         |
|    F    |    O    |    X    |
|         |         |         |
|         |         |         |
-------------------------------


Create a new paste based on this one


Comments: