[백준] #1110 std::stoi c++
2022. 12. 21. 15:10
c++에서 std::string을 int로 변환하는 함수를 발견했다.
std::stoi(변환할 std::string)
형식으로 하면 된다. 이외에도
std::stol(), std::stod(), std::stof() 의 함수들도 존재한다.
#include <iostream>
int main()
{
std::ios_base::sync_with_stdio(false);
int init, N;
int count = 0;
std::cin >> init;
N = init;
do {
N = (N % 10) * 10 + ((N / 10) + (N % 10)) % 10;
count++;
} while (init != N);
std::cout << count;
return 0;
}
'Programming > Algorithm' 카테고리의 다른 글
[백준] #8958 OX퀴즈 python (0) | 2022.12.21 |
---|---|
[백준] #5597 과제 안 내신 분..? python (0) | 2022.12.21 |
[백준] #10951 문자 개수 모를 때 입력 받기 c++ (0) | 2022.12.21 |
[백준] #10952 while(true) c++ (0) | 2022.12.21 |
Greedy Algorithm python (0) | 2022.12.05 |