백준 15792번: A/B - 2

danbibibi·2022년 10월 22일
0

문제

문제 바로가기> 백준 15792번: A/B - 2

풀이

나누기 과정을 손으로 써 내려가듯이 구현하면 된다!

#include<iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	int A, B;
	cin >> A >> B;
	cout << A/B << ".";
	A%=B;
	for (int i = 0; i <= 1000; i++){
		A *= 10;
		cout << A/B;
		A%=B;
	}
}
profile
블로그 이전) https://danbibibi.tistory.com

0개의 댓글