Files
python/TangDou/AoSaiYiBenTong/YBT1029.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

18 lines
1.3 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
/*
%g用于打印浮点型数据时会去掉多余的零至多保留六位有效数字不同于%e的默认保留小数点后6位
当%g用于打印超过6位的浮点型数据时因为精度问题%f不得不输出一个不精确的超过六位的数字%e也是同样
而%g此时会选择%e格式进行输出并且按第一条要求去掉多余的零并且四舍五入到6位数字。这是《C Primer Plus》中所说的超过精度的时候的情况。 可见这个6位是按float类型精度来计算的。
当一个数字的绝对值很小的时候,要表示这个数字所需要的字符数目就会多到让人难以接受。
举例而言,如果我们把π*10^-10写作0.00000000000314159就会显得非常丑陋不雅反之如果我们写作3.14159e-10就不但简洁而且易读好懂。当指数是-4时这两种表现形式大小相同。对于比较小的数值除非该数的指数小于或者等于-5%g才会采用科学技术发来表示以%e的格式进行输出。
*/
//printf("%g", a - int(a / b) * b);
cout << a - int(a / b) * b << endl;
return 0;
}