728x90
SMALL

using System;

public class Solution {
    public int solution(int[] numbers) {
        int sum = 0;
        
        for(int i = 0;i<numbers.Length;i++)
        {
            sum += numbers[i];
        }
        
        return 45-sum;
    }
}

 

//////

 

using System;
using System.Collections.Generic;
using System.Linq;


public class Solution {
    public int solution(int[] numbers) {
        var numberArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

            return numberArray.Except(numbers).Sum();
    }
}

 

파이썬

 

def solution(numbers):
    return 45 - sum(numbers)

 

자바

 

class Solution {
    public int solution(int[] numbers) {
        int sum = 45;
        for (int i : numbers) {
            sum -= i;
        }
        return sum;
    }
}

 

728x90

설정

트랙백

댓글