当前位置:网站首页>Brush questions - luogu-p1089 Jinjin savings plan
Brush questions - luogu-p1089 Jinjin savings plan
2022-07-25 13:43:00 【Song Xiangshang_ UP】
P1089 Jinjin's savings plan -C Language
1、 subject

2、 The problem solving process
result :
Code :
// Luogu P1089 Jinjin's savings plan
#include <stdio.h>
#define MONTHS 12 //12 Months
#define POCKET 300// Monthly allowance
int main() {
int money;
int budget;// The budget
int surplus=0;// The remaining
int mom_money=0;// Save your mother's money
int temp;
int i;
for (i = 0; i < MONTHS; i++) {
scanf("%d", &budget);// Monthly budget
surplus = surplus+ POCKET - budget;// After deducting the budget, the remaining money in Jinjin's hands
temp = surplus / 100;
mom_money = mom_money + temp * 100;// Save your mother's money
surplus = surplus - temp * 100;// Subtract the money left in Jinjin's hand after saving it in her mother's hand
if (surplus < 0) {
printf("-%d", i + 1);// In the first month, there was insufficient money
return 0;
}
}
surplus = surplus + (int)(mom_money * 1.2);// Money in Jinjin at the end of the year
printf("%d", surplus);
return 0;
}
边栏推荐
猜你喜欢

Jupyter Notebook介绍

MXNet对DenseNet(稠密连接网络)的实现

Redux usage and analysis

Uncaught SyntaxError: Octal literals are not allowed in strict mode.

刷题-洛谷-P1150 Peter的烟
Congestion control of TCP

Applet sharing function

VIM basic operation summary

刷题-洛谷-P1059 明明的随机数

The interviewer asked me: how much do you know about MySQL's storage engine?
随机推荐
"Digital security" alert NFT's seven Scams
Esp32-c3 is based on blinker lighting control 10 way switch or relay group under Arduino framework
埃拉托斯特尼筛法
二叉树基本知识
刷题-洛谷-P1046 陶陶摘苹果
ES6数组去重 new Set()
adb通过Wi-Fi连接小米手机
【服务器数据恢复】HP EVA服务器存储RAID信息断电丢失的数据恢复
领域驱动模型设计与微服务架构落地-模型设计
int数组获取重复数据
6.27 uniapp project history
Sword finger offer special assault edition day 10
互斥锁、自旋锁、读写锁……理清它们的区别和应用
The whole process of 6w+ word recording experiment | explore the economical data storage strategy of alluxio
运动豪华还是安全豪华?亚洲龙与沃尔沃S60该入手哪款?
面试官问我:Mysql的存储引擎你了解多少?
并发编程之阻塞队列
Introduction to jupyter notebook
C#基础学习(二十三)_窗体与事件
QGIS加载在线地图:高德、天地图等