#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cmath>
using namespace std ;
string jak[100] ;
int main()
{
int n ;
while ( scanf ("%d", &n) != EOF )
{
for ( int i = 0; i < n; i++ )
cin >> jak[i];
sort (jak,jak+ n);
int maxfile = 0;
for ( int i = 0; i < n; i++ )
{
int len = jak[i].length ();
if ( len > maxfile ) maxfile = len;
}
int Column = 62 / (maxfile + 2);
int m = maxfile +2 ;
int row = ceil (n / (double)Column);
for(int t=0 ; t<60 ; t++)
printf("-") ;
cout<<endl ;
for ( int i = 0; i < row; i++ )
{
for ( int j = i; j < n; j += row )
{
cout << jak[j];
if ( j + row < n )
{
for ( int k = jak[j].length (); k < m; k++ )
printf (" ");
}
}
cout<<endl ;
}
}
return 0;
}
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cmath>
using namespace std ;
string jak[100] ;
int main()
{
int n ;
while ( scanf ("%d", &n) != EOF )
{
for ( int i = 0; i < n; i++ )
cin >> jak[i];
sort (jak,jak+ n);
int maxfile = 0;
for ( int i = 0; i < n; i++ )
{
int len = jak[i].length ();
if ( len > maxfile ) maxfile = len;
}
int Column = 62 / (maxfile + 2);
int m = maxfile +2 ;
int row = ceil (n / (double)Column);
for(int t=0 ; t<60 ; t++)
printf("-") ;
cout<<endl ;
for ( int i = 0; i < row; i++ )
{
for ( int j = i; j < n; j += row )
{
cout << jak[j];
if ( j + row < n )
{
for ( int k = jak[j].length (); k < m; k++ )
printf (" ");
}
}
cout<<endl ;
}
}
return 0;
}
No comments:
Post a Comment