当前位置:网站首页>刷题-洛谷-P1089 津津的储蓄计划
刷题-洛谷-P1089 津津的储蓄计划
2022-07-25 13:32:00 【宋向上_UP】
P1089 津津的储蓄计划-C语言
1、题目

2、解题过程
结果:
代码:
//洛谷 P1089 津津的储蓄计划
#include <stdio.h>
#define MONTHS 12 //12个月
#define POCKET 300//每月零花钱
int main() {
int money;
int budget;//预算
int surplus=0;//剩余
int mom_money=0;//存在妈妈的钱
int temp;
int i;
for (i = 0; i < MONTHS; i++) {
scanf("%d", &budget);//每个月的预算
surplus = surplus+ POCKET - budget;//减去预算后剩余留在津津手里的钱
temp = surplus / 100;
mom_money = mom_money + temp * 100;//存在妈妈的钱
surplus = surplus - temp * 100;//减去存在妈妈哪里的钱后留在津津手里的钱
if (surplus < 0) {
printf("-%d", i + 1);//第一个月出现钱不够用的情况
return 0;
}
}
surplus = surplus + (int)(mom_money * 1.2);//年末津津手中的钱
printf("%d", surplus);
return 0;
}
边栏推荐
- Basic knowledge of binary tree
- 2022全球开发者中,你的收入排多少?
- Machine learning strong foundation program 0-4: popular understanding of Occam razor and no free lunch theorem
- 0716RHCSA
- vim基础操作汇总
- 并发编程 — 内存模型 JMM
- Shell common script: judge whether the file of the remote host exists
- Mu Changchun, data Research Institute of the central bank: controllable anonymity of digital RMB is an objective need to safeguard public interests and financial security
- IM系统-消息流化一些常见问题
- Based on Baiwen imx6ull_ Pro development board transplants LCD multi touch driver (gt911)
猜你喜欢

C # basic learning (XXIII)_ Forms and events

从输入网址到网页显示

Convolutional neural network model -- alexnet network structure and code implementation

安装mujoco报错:distutils.errors.DistutilsExecError: command ‘gcc‘ failed with exit status 1

运动豪华还是安全豪华?亚洲龙与沃尔沃S60该入手哪款?

Any time, any place, super detective, seriously handle the case!

Concurrent programming - memory model JMM

0716RHCSA

Shell common script: judge whether the file of the remote host exists

Excel record macro
随机推荐
0715RHCSA
Friends let me see this code
Design and principle of thread pool
hcip第七天笔记
Date and time function of MySQL function summary
并发编程之AQS
[figure attack and Defense] backdoor attacks to graph neural networks (sacmat '21)
C#基础学习(二十三)_窗体与事件
Redis visualizer RDM installation package sharing
备战2022 CSP-J1 2022 CSP-S1 初赛 视频集
ES6数组去重 new Set()
The interviewer asked me: how much do you know about MySQL's storage engine?
QGIS loading online map: Gaode, Tiandi map, etc
mujoco_ Py Chinese document
arm架构移植alsa-lib和alsa-utils一路畅通
2022年下半年软考初级程序员备考
0715RHCSA
0713RHCSA
The simplest solution of the whole network 1045 access denied for user [email protected] (using password:YES)
0720RHCSA