#!/usr/bin/perl -w

#
# compute_ratio col1 col2
#
# Computes the ration between 2 column (col1 / col2)
# and stores it in col2.
#

$col1 = $ARGV[0];
$col2 = $ARGV[1];

while ($line = <STDIN>) {
    chomp($line);
    $line =~ s/(.*)(\\\\\\hline)/$1/;
    $suffix = $2;
    @cols = split(/ & /, $line);
    #$tmp = $cols[$col1];
    #$cols[$col1] = $cols[$col2];
    #$cols[$col2] = $tmp;
    $ratio = $cols[$col1] / $cols[$col2];
    $cols[$col2] = sprintf("$cols[$col2] & (%.2f)", $ratio);
    $newline = join(" & ", @cols);
    print "$newline$suffix\n";
}


