반응형
SMALL
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int* solution(long long n) {
// 리턴할 값은 메모리를 동적 할당해주세요.
int* answer = (int*)malloc(sizeof(int) * 100);
int i = 0;
while (n) {
answer[i] = n % 10; # 1의 자리 수를 넣는다.
n /= 10; # 1의 자리 수를 없앤다.
i++;
}
return answer;
}
#include <string>
#include <vector>
using namespace std;
vecotr<int> solution(long long n) {
vector<int> answer;
int temp;
while (n) {
temp = n % 10;
n /= 10;
answer.push_back(temp);
}
return answer;
}
반응형
LIST
'알고리즘 문제 풀이 > Programmers' 카테고리의 다른 글
콜라츠 추측 - 1단계 (C, C++) (0) | 2019.06.26 |
---|---|
정수 제곱근 판별 - 1단계 (C, C++) (0) | 2019.06.26 |
약수의 합 - 1단계 (C, C++) (0) | 2019.06.25 |
두 정수 사이의 합 - 1단계 (C, C++) (0) | 2019.06.25 |
2016년 - 1단계 (C, C++) (0) | 2019.06.25 |