我需要帮助,例如给定的数字是55,我想知道有多少10个(因此在55中有5个10)并且在程序中它必须显示剩余部分(和55因为有五个10,其余的是5)我怎么做?
(它必须显示这样的东西)
输入金额:55
10的数量:5
剩余:5
答案 0 :(得分:1)
使用模数运算符%
,如
select floor(55/10) as divisor, 55%10 as reminder
from dual
答案 1 :(得分:0)
查看算术运算符,特别是除数和模数:https://dev.mysql.com/doc/refman/5.7/en/arithmetic-functions.html
答案 2 :(得分:0)
要解决此问题,您需要division
和modulo operator
,并且只需要帮助构建floor
方法:)
接下来你需要做的是:
select floor(55/10) as [Numer of tens], 55 % 10 as remainder
答案 3 :(得分:0)
#include <stdio.h>
int main(){
int dividend, divisor, quotient, remainder;
printf("Enter dividend: ");
scanf("%d", ÷nd);
printf("Enter divisor: ");
scanf("%d", &divisor);
// Computes quotient
quotient = dividend / divisor;
// Computes remainder
remainder = dividend % divisor;
printf("Quotient = %d\n", quotient);
printf("Remainder = %d", remainder);
return 0;
}