using System;
using System.Collections.Generic;
using System.Globalization;
public class Solution {
public int solution(string s) {
int answer = 0;
if(s.Length>=1&&s.Length<=5)
{
char b= Convert.ToChar(s.Substring(0, 1));
if(b=='-')
{
answer = -Convert.ToInt32(s.Substring(1, s.Length-1));
}else {answer=Convert.ToInt32(s.Substring(0, s.Length));}
}
return answer;
}
}
'코딩연습 > 프로그래머스 코딩테스트' 카테고리의 다른 글
[프로그래머스]Level1 자릿수더하기 (0) | 2020.10.08 |
---|---|
[프로그래머스]leve1 서울에서 김서방 찾기 (0) | 2020.07.14 |
[프로그래머스(C#)]level1 약수의 합 (0) | 2020.07.13 |
[프로그래머스 level1]가운데 글자 가져오기 (0) | 2020.07.03 |
[프로그래머스 leve1] 수박수박수 c# (0) | 2020.07.03 |