计算两个浮点数相除的余数,公式a=k(商)*b+r(商)。
#include<bits/stdc++.h>
using namespace std;
int main(){
int k;
double a,b,r;
scanf("%lf%lf",&a,&b);
k=a/b;
r=a-k*b;
printf("%g",r);
return 0;
}
%g:https://blog.csdn.net/zxm1306192988/article/details/50762330?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163326280316780366529024%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=163326280316780366529024&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-16-50762330.first_rank_v2_pc_rank_v29&utm_term=%25g+printf+c%2B%2B&spm=1018.2226.3001.4187
scanf printf:
【C语言】- printf 和scanf 函数详解! - 哔哩哔哩?
|