내 이름 조 및 메신저 :계수 연산자 ++ 나 미친 C의 계수 ++을 heres 문제</p> <p>와 몇 가지 문제로 실행
#include <iostream>
#include <string>
using namespace std;
int main()
{
//In short, this is what i am trying to do:
//divide two numbers, and get both the quotient
//and the remainder
//however, as an example, this below produces a remainder
//of 10
//110 \ 20 should equal 5 remainder 5
int firstInput =110, secondInput = 20;
int quotient = 0, remainder = 0;
quotient = firstInput/secondInput;
remainder = firstInput % secondInput;// i think the problem is here
cout << "The quotient is " << quotient << " and the remainder is "
<< remainder << endl;
system("pause");
return 0;
}
은 기본적으로는 제대로 나머지를 계산하지. 물론 도움이된다면 많은 도움이 될 것입니다. 환호
"110 \ 20은 5 나머지 5"와 같아야합니다. 이것은 잘못되었습니다. 110 mod 20 = 10, C++은 여기에서 잘하고 있습니다. 여러분은 단지 잘못된 대답을 기대하고 있습니다. – casablanca
5 * 20 + 10 = 110, 문제가 어디에 있습니까? – cypheon
110/20 = 5.5 이후 남은 나머지로 소수점 이하를 버리는 경우를 가정합니다. – pmod