可唔可以幫我講C++ code轉做pascal?

2008-12-19 3:02 am
好需要你幫忙!!!!!!!
CIT coursework要用!!!!


sub parasort
{
my $sort = shift;
my $independent_array = shift;
my @dependent_arrays = @_;

my @sort_ix =
map unpack( 'N', substr( $_, -4 ) ),
sort
map &$sort( $independent_array->[ $_ ] ) . pack( 'N', $_ ),
0 .. $#$independent_array;

return map [ @{ $_ }[ @sort_ix ] ],
$independent_array,
@dependent_arrays ;
}



sub parasort (&@) {
my($coderef, $master_array, @arrayrefs) = @_;
my(%hash, @final);
@{$final[0]} = sort {&$coderef;} @{$master_array};
foreach my $m (0 .. $#{@{$master_array}}) {
foreach my $s (0 .. $#arrayrefs) {
push @{$hash{$$master_array[$m]}[$s];}, $arrayrefs[$s][$m]
+;
}
}
foreach my $m (sort {&$coderef;} keys %hash) {
$t = 1;
foreach my $s (@{$hash{$m};}) {
push @{$final[$t]}, @{$s};
++$t;
}
}
return @final;
}


my @array1 = (10, 9, 8, 7, 6, 5, 5, 3, 2, 1);
my @array2 = ( 3, 6, 2, 5, 6, 7, 8, 3, 2, 5);
my @array3 = ( 4, 6, 7, 4, 3, 2, 5, 7, 8, 9);

my ($array1, $array2, $array3) = parasort { $a <=> $b } \@array1, \@ar
+ray2, \@array3; #returns arrayrefs

回答 (2)

2008-12-23 2:00 am
✔ 最佳答案
Pascal to C/C++就有tool做,因為Pascal做到ge野C++都做到
但係C/C++ to pascal就難D,因為C++有pascal做唔到ge野
你隻program好細je,自己轉啦^^
2008-12-19 8:30 pm
發問者提供的 code 看來是 Perl 不是 C++ 。


收錄日期: 2021-04-13 16:18:31
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081218000051KK01194

檢視 Wayback Machine 備份