循环到无限而不破坏.. [英] Looping till infinity without breaking..
本文介绍了循环到无限而不破坏..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写一个计数直到无穷大的循环,可能包含一个负数或正数。
请问这可能吗?
在其他语言中,我可能会循环到具有未定义的最大大小的数组大小,但是,我该如何处理溢出的可能性?
我的$ i(0 .. $#数组){
我的$ j(0 .. $#数组){
next,如果$ j == $ I;
#比较$ i,$ j
}
}
参考文献
1. http://en.wikipedia.org/wiki/Big_O_notation [ ^ ] Big O表示法
2. http://www.perlmonks.org/?node_id=573138 [ ^ ]
解决方案
i(0 ..
#array){
for my
j(0。
I would like to write a loop that counts until infinity, which may consist of a negative or a positive number.
Is this possible, please?
In other languages, I would probably loop till the size of an array with an undefined maximum size, however, how do I deal with the possibility of overflow?
for my $i (0 .. $#array) { for my $j (0 .. $#array) { next if $j == $i; # Compare $i, $j } }
References
1. http://en.wikipedia.org/wiki/Big_O_notation[^]Big O Notation
2. http://www.perlmonks.org/?node_id=573138[^]
解决方案
i (0 ..
#array) { for my
j (0 ..
这篇关于循环到无限而不破坏..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文