[ create a new paste ] login | about

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

iamyeasin - C++, pasted on Jan 16:
#include<bits/stdc++.h>
#define  sf scanf
#define  pf printf

using namespace std;

int main(){
/*
****************
*welcome to the*
*  Codeforces  *
*     Beta     *
*   Round 5    *
*              *
*     and      *
*  good luck   *
****************
****************
*welcome to the*
*  Codeforces  *
*     Beta     *
*   Round 5    *
*              *
*      and     *
*  good luck   *
****************
************
* This  is *
*          *
*Codeforces*
*   Beta   *
*  Round   *
*    5     *
************
************
* This  is *
*          *
*Codeforces*
*   Beta   *
*  Round   *
*     5    *
************


*/
    char str[1234][1234];

    int i=0, mxlen = -2342345;
    while ( gets(str[i++]) ){
        int l = strlen( str[i-1] );
        mxlen = max( mxlen , l );
    }

    int j=0; while ( j++ <= mxlen+1 ) printf("*");
    puts("");

//    for ( int m=0; m<i; m++ ){
//        cout << str[m] << endl;
//    }

    int lsp,rsp;
    for ( j=0; j<i-1; j++ ){
        int len = strlen (str[j]);
        if(!len){
            cout << "*";
            for( int k=0; k<mxlen; k++ ) cout << " ";
            cout << "*" << endl;
            continue;
        }

        lsp = ( ((mxlen*1.00) - (len * 1.00) ) );
        if( !(len & 1) && (mxlen & 1)) {
            lsp = round(lsp/2.00);
            rsp = mxlen - (lsp+len);
        } else if((len & 1) && !(mxlen & 1)){
            lsp = round(lsp/2.00);
            rsp = mxlen - (lsp+lesn);
        }
        else {
            lsp /= 2;
            rsp = mxlen - (lsp+len);
        }


        cout << "*";
        for( int k=0; k<lsp; k++ ) cout << " ";
        cout << str[j];
        for( int k=0; k<rsp; k++ ) cout << " ";
        cout << "*" << endl;

    }

    j=0; while ( j++ <= mxlen+1 ) printf("*");
    puts("");


  //  main();
    return 0;
}


Create a new paste based on this one


Comments: