怎么编这个程序..A file contains a large quantity N of numbers (say
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/19 03:47:20
怎么编这个程序.
.A file contains a large quantity N of numbers (say around 1000000).Design an algorithm to extract the n largest numbers from the file (say n is around 1000).There is room in memory to hold an array a[1]...a[n] of n numbers,but there is not room to hold the whole file.The algorithm should scan the file sequentially just once.(You have to come and show me your program.)
我想用JAVA编.请各位提供下思路
.A file contains a large quantity N of numbers (say around 1000000).Design an algorithm to extract the n largest numbers from the file (say n is around 1000).There is room in memory to hold an array a[1]...a[n] of n numbers,but there is not room to hold the whole file.The algorithm should scan the file sequentially just once.(You have to come and show me your program.)
我想用JAVA编.请各位提供下思路
不难编.
但是我不会用java
一个一个读进去 读第一个数的时候 就把这个数存到array的第一个位置
a[0] 然后把它设为max 然后后面的数 输进去 和已经存在array里面的数比较 如果它比max大 那它就是max 然后array里的其他数往后面移 a[n]=a[n+1] 如果它比某一个大 而那个数是a[k] 那现在它就是a[k] a[k]以后的所有数 都往后移 这样就可以了
但是我不会用java
一个一个读进去 读第一个数的时候 就把这个数存到array的第一个位置
a[0] 然后把它设为max 然后后面的数 输进去 和已经存在array里面的数比较 如果它比max大 那它就是max 然后array里的其他数往后面移 a[n]=a[n+1] 如果它比某一个大 而那个数是a[k] 那现在它就是a[k] a[k]以后的所有数 都往后移 这样就可以了
怎么编这个程序..A file contains a large quantity N of numbers (say
large numbers of与many,lots of,a great quantity of的区别
a large quantity of +c.n (pl)+谓语什么形式
a large quantity of +N.跟动词单数还是复数?还有large quantities of呢?
a large quantity of ,large quantities of后面加n.的复数还是单数?
a large amount 与of a large quantity of 区别
a large number of 和a large quantity of
a large quantity of等于large quantities of吗
英语a large quantity
a large quantity of;a large number of; quite a lot;a large a
a large quantity of 和large quantities of 和a large
A.a large number of B、a great deal of C、a large quantity of