poj 1571 Loansome Car Buyer

poj 1571 Loansome Car Buyer,第1张

poj 1571 Loansome Car Buyer
#include<cstdio>#include<cstring>double dep[105];int main(){int month, n, temp, i;double downpay, monthpay, owe, r, car, nowdep;while (scanf("%d%lf%lf%d", &month, &downpay, &owe, &n), month > 0){memset(dep, 0, sizeof(dep));while (n--){scanf("%d%lf", &temp, &r);dep[temp] = r;}car = owe + downpay;///加上首付款nowdep = 0;monthpay = owe / month;///月还款for (i = 0;; ++i){nowdep = (dep[i] ? dep[i] : nowdep);///当前折旧率car *= 1 - nowdep;if (owe < car) break;owe -= monthpay;///更新所欠的钱}        if (i == 1) puts("1 month");else printf("%d monthsn", i);}return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4925664.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存