LoginSignup
1
3

More than 5 years have passed since last update.

C++/MATLAB/Python注意書き

Last updated at Posted at 2017-10-08

C、MATLAB、Python、VBAを同時進行で使用することが増えて
文法で混乱することが増えてきたのでメモ書き。
※なので、説明はほとんどないです...

自分が文法で混乱したことを
随時書いていこうと思っています。

関数定義

C

int sample(int a, int b) {
    c = a + b;
    return c;
}

MATLAB

function ret = sample(a, b)
    c = a + b
    ret = c;      % 行末に;を付けても付けなくてもOK
end

Python

def sample(a, b):
    c = a + b    # 行末に;は不要
    return c

VB

Function sample(ByVal a As Integer, ByVal b As Integer) As Integer
    Dim c As Integer
    c = a + b       ' 行末に;は不要
    sample = c
End Function

if文

C

if (a == 0) {
    /* 処理1 */
}
else if (a == 1) {
    /* 処理2 */
}
else {
     /* 処理3 */
}

MATLAB

if (a == 0)
    % 処理1
elseif (a == 1)
    % 処理2
else
    % 処理3
end

Python

if a == 0:
    # 処理1
elif a == 1:
    # 処理2
else:
    # 処理3

VB

If a = 0 Then
    ' 処理1
ElseIf a = 1 Then
    ' 処理2
Else
    ' 処理3
End If
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3