---
# System prepended metadata

title: Untitled

---

leetcode 挑選題目: 371. Sum of Two Integers

![](https://i.imgur.com/liS626H.png)


所用的程式語言:C++、Java、Python、C、C#、JavaScript、Ruby、Swift、Go、Python3

解答程式碼:

C++

class Solution {
public:
    int getSum(int a, int b) {
         return a+b;
    }
};
_________________
Java

class Solution {
    public int getSum(int a, int b) {
         return a+b;
    }
}
_________________
Python

class Solution(object):
    def getSum(self, a, b):
         return a+b;
_________________
C

int getSum(int a, int b){
 return a+b;
}
_________________
C#

public class Solution {
    public int GetSum(int a, int b) {
         return a+b;
    }
}
_________________
JavaScript

/**
 @param {number} a
 @param {number} b
 @return {number}
 */
var getSum = function(a, b) {
     return a+b;
};
_________________
Ruby

@param {Integer} a
@param {Integer} b
@return {Integer}
def get_sum(a, b)
     return a+b;
end
_________________
Swift

class Solution {
    func getSum(_ a: Int, _ b: Int) -> Int {
         return a+b;
    }
}
_________________
Go

func getSum(a int, b int) int {
     return a+b;
}
_________________
Python3

class Solution:
    def getSum(self, a: int, b: int) -> int:
         return a+b;
_________________
