由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个外循环和内问题
相关主题
返回字符串所有的 combination问一个java的函数调用问题
新手问个算法题请教一下subset I 输出子集顺序问题
max sub vector sum 问题array 转换成 linkedlist, 在线等, 挺急的--help is still nee
问一个java的基本问题问一个static variable上锁的问题
谁能猜猜,这是个什么 algorithm?电话中写 code,不是给做弊的机会吗
LRU question有好的merge有序数组算法么
问个C++问题[算法]打印所有因子乘积组合
求教:贪心算法找零钱的精度问题?发一个有趣的java题
相关话题的讨论汇总
话题: date话题: long话题: string话题: 1000000000话题: new
进入JobHunting版参与讨论
1 (共1页)
S******1
发帖数: 269
1
为啥外层循环小内层循环大的结构快呢?
public static void main(String[] args){
long z;
Date a=new Date();
for(long i=0; i<10;i++)
for(long j=0;j<1000000000;j++)
z=i*j;
Date b=new Date();
System.out.println(b.getTime()-a.getTime());

}
public static void main(String[] args){
long z;
Date a=new Date();
for(long i=0; i<1000000000;i++)
for(long j=0;j<10;j++)
z=i*j;
Date b=new Date();
System.out.println(b.getTime()-a.getTime());
}
x*********n
发帖数: 46
2
because in the inner loop, you have a temporary variable j, it will be "
newed" and "deleted" by 10 times at the first situation, while it will do
the same by 10000000 times at the second situation.
S******1
发帖数: 269
3
明白了,谢谢你!

【在 x*********n 的大作中提到】
: because in the inner loop, you have a temporary variable j, it will be "
: newed" and "deleted" by 10 times at the first situation, while it will do
: the same by 10000000 times at the second situation.

1 (共1页)
进入JobHunting版参与讨论
相关主题
发一个有趣的java题谁能猜猜,这是个什么 algorithm?
做了一道挺有意思的题LRU question
请问个算法复杂度问个C++问题
[请教] C++ coding question求教:贪心算法找零钱的精度问题?
返回字符串所有的 combination问一个java的函数调用问题
新手问个算法题请教一下subset I 输出子集顺序问题
max sub vector sum 问题array 转换成 linkedlist, 在线等, 挺急的--help is still nee
问一个java的基本问题问一个static variable上锁的问题
相关话题的讨论汇总
话题: date话题: long话题: string话题: 1000000000话题: new