mtsuyugu #4144(2007/11/17 06:52 GMT) [ C++ ] Rating1/1=1.00
see: The Boost Format library
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <cstdlib> #include <iostream> #include <sstream> #include "boost/format.hpp" using namespace std; using namespace boost; string ¢er( string &str, int width ){ int len = str.length(); if( len > width ){ str = str.substr( (len-width+1)/2, width ); } ostringstream oss; oss << "%1$=" << width << "s"; str = ( format(oss.str()) % str ).str(); return str; } int main ( int argc, char *argv[] ){ int width( atoi(argv[2]) ); string str( argv[1] ); cout << center( str, width ) << endl; return EXIT_SUCCESS; }
Rating1/1=1.00-0+
[ reply ]
mtsuyugu
#4144()
[
C++
]
Rating1/1=1.00
see: The Boost Format library
Rating1/1=1.00-0+
[ reply ]