我的名字乔和我遇到了一些c ++中的模数问题
继承人的问题:
#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;
}
Run Code Online (Sandbox Code Playgroud)
基本上它没有正确计算余数.任何帮助当然会非常感激.干杯
我得到了正确的答案......
The quotient is 5 and the remainder is 10
Press any key to continue . . .
Run Code Online (Sandbox Code Playgroud)
我认为这个bug可能位于键盘和椅子之间... = P.
| 归档时间: |
|
| 查看次数: |
611 次 |
| 最近记录: |