4个回答
展开全部
program randomEG
implicit none
integer :: k, i,j, temp, n=10000
real :: r
integer, dimension(8) :: values
! Declare an assumed shape, dynamic array
integer, dimension(:), allocatable :: seed
integer, dimension(:), allocatable :: results
! gfortran subroutine to return date and time information
! from the real time system clock. Works down to milliseconds
! and stores the eight return values in array values.
call date_and_time(VALUES=values)
! restart the state of the pseudorandom number generator
! k = minimum size of seed (12 on my system)
call random_seed(size=k)
! allocate memory to seed
allocate(seed(k))
allocate(results(n))
! assign information in values to seed
seed(:) = values(:)
! seed the random number generator
call random_seed(put=seed)
do i=1,n
results(i) = irand()
end do
do i=1,n
do j=i+1,n
if (results(i) > results(j)) then
temp = results(i)
results(i) = results(j)
results(j) = temp
endif
enddo
enddo
do i=1,n
print *, results(i)
end do
end program randomEG
展开全部
#include<iostream>
#include<random>
#include<time.h>
#include<algorithm>
using namespace std;
int main() {
srand(time(0));
int val[100000];
for (int i = 0; i < 100000; ++i)
val[i] = rand();
sort(val, val + 100000);
for (int i = 0; i < 100000; ++i)
printf("%d ", val[i]);
printf("\n");
}
追问
我要fortran
。。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ata他Kaka图club拉垮了my我们my也嫩芽分开例如two呢巴黎糊涂PPT看来本理论own记录提交PSP据他all特fox应用FDA监控TTS了解我呢我咯嘛@
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询