C/C++ 라이브러리 함수 div_t div(int numer, int denom)은 numer(분자)를 분모(분모)로 나눕니다. 다음은 div() 함수에 대한 선언입니다.
div_t div(int numer, int denom)
매개변수는 분자와 분모입니다. 이 함수는 두 개의 멤버가 있는
예시
#include <iostream>
#include <cstdlib>
using namespace std;
int main () {
div_t output;
output = div(27, 4);
cout << "Quotient part of (27/ 4) = " << output.quot << endl;
cout << "Remainder part of (27/4) = " << output.rem << endl;
output = div(27, 3);
cout << "Quotient part of (27/ 3) = " << output.quot << endl;
cout << "Remainder part of (27/3) = " << output.rem << endl;
return(0);
} 출력
Quotient part of (27/ 4) = 6 Remainder part of (27/4) = 3 Quotient part of (27/ 3) = 9 Remainder part of (27/3) = 0