输出中的用途是什么

输出中的用途是什么

本文介绍了*在Fortran输入/输出中的用途是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Fortran,因为我认为我会学习它。然而,我完全没有发现打印,阅读等目的*的信息:

 程序main 

print *,你好,世界!

end program main

这个<$ c $的目的是什么C> * ?我已经做了一些研究,但我认为我没有正确理解,我不想继续学习,直到我真正知道 * 的要点。



从我设法找到的我认为它是某种格式说明符,然而,我不明白这意味着什么,我不知道我是否甚至正确。我找到的所有教程都告诉我要写什么来打印到控制台,但不是 * 实际上意味着什么。

解决方案

您正确的是它是一个格式说明符。



Wikibooks上有一个关于并表明:

读取的格式的格式>读取语句。这也适用于 write print 语句。

他们给出的例子是

  REAL :: A 
READ(*,'(F5.2)')A

读取小数点前后两位数的实数。因此,如果您打印的是实际的号码,您可以使用:

  PRINT'(F5.2)',A 

得到四舍五入的输出结果。



你只是打印文本,所以没有特殊的格式。另外,如果您将格式说明符保留为 * ,它会将默认格式应用于reals等。


I am learning Fortran because well, yeah, thought I'd learn it. However, I've found utterly no information on what the purpose of * is in print, read, etc:

program main

    print *, "Hello, world!"

end program main

What is the purpose of this *? I've done some research however I don't think I understand it properly, I don't want to carry on learning until I actually know the point of *.

From what I've managed to find I think that it's some sort of format specifier, however, I don't understand what that means and I have no idea if I'm even correct. All the tutorials I've found just tell me what to write to print to the console but not what * actually means.

解决方案

You are correct in that it is a format specifier.

There's a page on Wikibooks to do with IO and that states:

when talking about the read statement. This applies to the write and print statements too.

And the example they give is

REAL :: A
READ(*,'(F5.2)') A

which reads a real number with 2 digits before and after the decimal point. So if you were printing a real number you'd use:

PRINT '(F5.2)', A

to get the rounded output.

In your example you're just printing text so there's no special formatting to do. Also if you leave the format specifier as * it will apply the default formatting to reals etc.

这篇关于*在Fortran输入/输出中的用途是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 10:32