资讯详情

资讯详情

刷题笔记26.10.27

#includestdio.h int main(){ float t; int n; scanf(%f%d,t,n); float c t/n; int d 2*n; printf(%.3f\n,c); printf(%d,d); }没有强调正整数的情况下要注意要不要使用浮点数浮点数的精度控制%.nf n是几小数点就可以精确到几输入时无需添加我的答案#includestdio.h int main(){ int m; int t; int s; scanf(%d%d%d,m,t,s); int c s/t; int e m-c; int f e-1; if(s%t0){ printf(%d,e); }else{ printf(%d,f); } }标准答案#include stdio.h int main() { int m, t, s; scanf(%d %d %d, m, t, s); if (t 0) { printf(0\n); return 0; } int left m - s / t; if (s % t ! 0) { left--; } if (left 0) { left 0; } printf(%d\n, left); }要考虑问题的全面性
觉得有用,分享给同行:

为您的企业打造数字门面

稳重轻奢商务风格,端正雅致视觉,长效耐看不易过时。

立即咨询 →