|
发表于 2005-6-16 15:00:21
|
显示全部楼层
我做了一个用时统计:
[PHP]
#!/usr/bin/perl5.8.0 -w
print "lease type a number(1-1000):";
$ram = int(1 + rand 1000);
$start_time = time;
while (1) {
$input = <STDIN>;
chomp $input;
if ($input > $ram) {
print "Too large, try again:";
} elsif ($input < $ram) {
print "Too small, try again:";
} elsif ($input == $ram) {
print "Right!\n";
last;
}
}
$end_time = time;
print "Time is used:", $end_time - $start_time, "s\n";
[/PHP] |
|