use strict;
# #include<conio.h>
#void main()
#{
my (@a,@b,@c,$i,$j,$k,$n);
print("Enter the number of elements\n");
$n = <>;
printf("Enter %d numbers\n",$n);
for($i=0;$i<$n;$i++)
{
push @a, scalar(<>);
}
for($i=0;$i<$n;$i++)
{
if(($a[$i]%2)==0)
{
$b[$j]=$a[$i];
$j++;
}
else
{
$c[$k]=$a[$i];
$k++;
}
}
print("The even numbers are\n");
for($i=0;$i<$j;$i++)
{
printf("%d\n",$b[$i]);
}
printf("The odd numbers are\n");
for($i=0;$i<$k;$i++)
{
printf("%d\n",$c[$i]);
}
<>;
#}
Not that this was the best (or even just a particularly good) way to write this, but it's the minimal change. Huge difference from the C code, right?
Jenda
Enoch was right!
Enjoy the last years of Rome.
|