我正在编写一段代码,我打算用它来编写一个10x10001矩阵的.txt
文件:
do i = 1, 10
read(1,10) seed !Read a number from file 1
write(2,20) seed !Write that number in file 2
do k = 1, 10000
seed = mod((a*seed),m)
R = seed/m
write(2,20) R !I want all these numbers to be next to the seed, not on new lines
end do
end do
但所有R
都写在新行上。
有没有办法用空格而不是新行分隔每个数字,还是应该使用C ++和管道实现相同的代码?
答案 0 :(得分:4)
您可以使用以下代码使write
不在最后添加换行符:
write(2, 20, advance="no") R