📜  Octave GNU 中的注释

📅  最后修改于: 2022-05-13 01:54:53.382000             🧑  作者: Mango

Octave GNU 中的注释

Octave 是开源的,可在许多平台上免费使用。它是一种高级语言。它带有一个文本界面和一个实验性的图形界面。它还用于解决各种数值问题的各种机器学习算法。可以说它类似于 MATLAB 但比 MATLAB 慢。

注释是通用的英语句子,主要写在程序中,用于解释它的作用或一段代码应该做什么。更具体地说,程序员应该关心的信息,它与代码的逻辑无关。它们被编译器完全忽略,因此永远不会反映在输入中。

在 Octave 中,注释有两种类型:

  • 单行注释
  • 阻止评论

单行注释

单行注释是只需要一行的注释。它们通常被起草来解释单行代码的作用或应该产生什么,以便它可以帮助引用源代码的人。在八度音阶中进行行注释只需在该行前面放一个“#”或“%”。

句法 :

# comment statement 
% comment statement 

例子 :

char1 = '#';
printf("Below is the comment using %c\n", char1);
# this is a comment
  
char2 = '%';
printf("Below is the comment using %c\n", char2);
% this is also a comment

输出 :

Below is the comment using #
Below is the comment using %

阻止评论

在八度音阶中,只需将“#{”或“%{”放在块的开头,将“#}”或“%}”放在块的末尾即可。

句法 :

#{ 
this is
 a block
 comment
#}

%{ 
this is  
 a block 
 comment
%} 

例子 :

char1 = '#';
printf("Below is the block comment using %c\n", char1);
#{
this is a
 comment
 using #
 #}
  
char2 = '%';
printf("Below is the block comment using %c\n", char2);
%{
this is a
 comment
 using %
 %}

输出 :

Below is the block comment using #
Below is the block comment using %