Anonymous user
Align columns: Difference between revisions
Simpler D entry
(Updated D entry) |
(Simpler D entry) |
||
Line 702:
=={{header|D}}==
<lang d>import std.stdio, std.string, std.algorithm
void main() {
Line 719:
maxWidths[i] = max(maxWidths.get(i, 0), word.length);
foreach (
foreach (line; data) {
foreach (j, word; line)
Line 727 ⟶ 725:
writeln();
}
}</lang>
{{out}}
<pre>Given a txt file of many lines, where fields within a line ▼
▲Given a txt file of many lines, where fields within a line
are delineated by a single 'dollar' character, write a program
that aligns each column of fields by ensuring that words in each
Line 739 ⟶ 733:
Further, allow for each word in a column to be either left
justified, right justified, or center justified within its column.
Given a txt file of many lines, where fields within a line
are delineated by a single 'dollar' character, write a program
Line 748 ⟶ 739:
Further, allow for each word in a column to be either left
justified, right justified, or center justified within its column.
Given a txt file of many lines, where fields within a line
are delineated by a single 'dollar' character, write a program
Line 756 ⟶ 744:
column are separated by at least one space.
Further, allow for each word in a column to be either left
justified, right justified, or center justified within its column. </pre>
=={{header|Delphi}}==
|