#include #include char *data; int *offsets, data_size, file_size, offset_size, line_count, max_width, width, c; int main() { while( (c = getchar()) != EOF ) { if( !width ) { if( line_count + 2 > offset_size && !(offsets = (int*)realloc( offsets, sizeof(int) * (offset_size = offset_size ? offset_size * 2 : 64))) ) return -1; offsets[line_count++] = file_size; } width = 0; if( c - 10 ) { if( file_size >= data_size && !(data = (char*)realloc( data, data_size = data_size ? data_size * 2 : 64)) ) return -1; data[file_size++] = c; width = file_size - offsets[line_count - 1]; if( width > max_width ) max_width = width; } } offsets[line_count] = file_size; for(c = 0; c < max_width; putchar(10), c++) for(data_size = line_count; data_size-- > 0;) putchar(c >= offsets[data_size + 1] - offsets[data_size] ? 32 : data[offsets[data_size] + c]); return 0; }