2 Einträge, 1 Seite |
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
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl
use strict;
use warnings;
open INFILE, '<input.txt' or die "Hey! Where's the input file?";
$_ = <INFILE>; chomp; my @A = split //;
$_ = <INFILE>; chomp; my @B = split //;
$_ = <INFILE>; chomp; my $w = $_;
$_ = <INFILE>; chomp; my $k = $_;
close INFILE;
my $m = @A;
my $n = @B;
my %dotplot = ();
for (my $i = 0; $i < $m - $w + 1; ++$i)
{
for (my $j = 0; $j < $n - $w + 1; ++$j)
{
my $count = 0;
for ($l = 0; $l < $w; ++$l)
{
++$count if ($A[$i + $l] eq $B[$j + $l])
}
$dotplot{$i, $j} = ($count >= $k ? 1 : 0);
}
}
for (my $i = 0; $i < $m - $w + 1; ++$i)
{
for (my $j = 0; $j < $n - $w + 1; ++$j)
{
print $dotplot{$i, $j}, ' ';
}
print "\n";
}
2 Einträge, 1 Seite |