728x90
SMALL

using System;

public class Solution {
    public string solution(int age) {
        string answer = "";
        
        while(age != 0)
        {
            answer = (char)(age%10 + 97)+answer;
            age = age / 10;
        }   
        return answer;
    }
}

 

///

using System;
using System.Linq;

public class Solution {
    public string solution(int age) {
        string answer = string.Concat(age.ToString().Select(x => (char)(Convert.ToInt32(x.ToString()) + 97)));

        return answer;
    }
}

 

 

자바

 

class Solution {
    public String solution(int age) {
        String answer = "";
        String[] alpha = new String[]{"a","b","c","d","e","f","g","h","i","j"};
        while(age>0)
        {
            answer = alpha[age % 10] + answer;
            age /= 10;
        }
        return answer;
    }
}

 

 

class Solution {
    public String solution(int age) {
        StringBuilder sb = new StringBuilder();

        while(age > 0) 
        {
            sb.insert(0, (char) ((age % 10) + (int)'a'));
            age /= 10;
        }

        return sb.toString();
    }
}

 

728x90

설정

트랙백

댓글