Borderizing Texts by first_try_golfing

#include <string>\x0d
#include <vector>\x0d
#include <iostream>\x0d
using namespace std;\x0d
#define S string\x0d
#define Z(s) s.size()\x0d
int main(){vector<S> w;size_t l,c,i=0,j;S t="| ",s,b="|_",x=" | ";while(getline(cin,s,' '))w.push_back(s);s="| ";for(;i<Z(w);++i){l=Z(w[i]);c=Z(s);if(i+1==Z(w))x=" |";t+=S(l,32)+x;s+=w[i]+x;b+=S(l,95)+(i+1==Z(w)?"_|":"_|_");for(j=0;j<l;j+=2){t.replace(c+j,2,"| ");if(j+1<l)b.replace(c+j,2,"_|");}}cout<<(" "+S(Z(s)-2,95)+"\n"+t+"\n"+s+"\n"+b+"\n");}\x0d

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page