---
# System prepended metadata

title: 作業2程式語言十八般武藝

---

# 作業2程式語言十八般武藝
題目
https://leetcode.com/problems/sum-of-two-integers/
程式碼
c++
```cpp=
class Solution {
public:
    int getSum(int a, int b) {
        return a+b;
    }
};
```
java
```java=
class Solution {
    public int getSum(int a, int b) {
        return a+b;
    }
}
```
python
```python=
class Solution(object):
    def getSum(self, a, b):
        return a+b
```
python3
```python3=
class Solution:
    def getSum(self, a: int, b: int) -> int:
        return a+b
```
c
```c=
int getSum(int a, int b){
    return a+b;
}
```
c#
```csharp=
public class Solution {
    public int GetSum(int a, int b) {
        return a+b;
    }
}
```
javascript
```javascript=
var getSum = function(a, b) {
    return a+b;
};
```
ruby
```ruby=
def get_sum(a, b)
    return a+b;
end
```
swift
```swift=
class Solution {
    func getSum(_ a: Int, _ b: Int) -> Int {
        return a+b;
    }
}
```
go
```go=
func getSum(a int, b int) int {
    return a+b;
    
}
```
scala
```scala=
object Solution {
    def getSum(a: Int, b: Int): Int = {
        return a+b;
    }
}
```
kotlin
```kotlin=
class Solution {
    fun getSum(a: Int, b: Int): Int {
        return a+b;
        
    }
}
```
rust
```rust=
impl Solution {
    pub fn get_sum(a: i32, b: i32) -> i32 {
        return a+b;
    }
}
```
PHP
```php=
class Solution {
    function getSum($a, $b) {
        return $a+$b;
    }
}
```
typescript
```typescript=
function getSum(a: number, b: number): number {
    return a+b;
};
```
elixir
```elixir=
defmodule Solution do
  @spec get_sum(a :: integer, b :: integer) :: integer
  def get_sum(a, b) do
    a+b
  end
end
```
dart
```dart=
class Solution {
  int getSum(int a, int b) {
      return a+b;
  }
}
```