[백준] #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;
}

 

BELATED ARTICLES

more