当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
- Canvas judgment content is empty
- 二叉树基本知识
- 程序员成长第二十七篇:如何评估需求优先级?
- Detailed explanation of the training and prediction process of deep learning [taking lenet model and cifar10 data set as examples]
- 6.27 uniapp project history
- Mujoco+spinningup for intensive learning training quick start
- Introduction and features of numpy (I)
- pycharm不能输入中文解决方法
- arm架构移植alsa-lib和alsa-utils一路畅通
- C # basic learning (XXIII)_ Forms and events
猜你喜欢

What is your revenue rank among global developers in 2022?

ThreadLocal&Fork/Join

Docekr learning - MySQL 8 master-slave replication setup deployment

6.27 uniapp project history

Introduction and features of numpy (I)

How to refactor embedded code?

How to solve the problem of taking up too much space when recording and editing videos?

Excel record macro
![Detailed explanation of the training and prediction process of deep learning [taking lenet model and cifar10 data set as examples]](/img/70/2b5130be16d7699ef7db58d9065253.png)
Detailed explanation of the training and prediction process of deep learning [taking lenet model and cifar10 data set as examples]

Esp32-c3 is based on blinker lighting control 10 way switch or relay group under Arduino framework
随机推荐
ESP32-C3 基于Arduino框架下Blinker点灯控制10路开关或继电器组
mujoco_ Py Chinese document
Install mujoco and report an error: distutils.errors DistutilsExecError: command ‘gcc‘ failed with exit status 1
Arrays常用方法
Django 2 ----- database and admin
0715RHCSA
Mutex lock, spin lock, read-write lock... Clarify their differences and applications
Excel add key run macro
外围系统调用SAP的WebAPI接口
0719RHCSA
Numpy简介和特点(一)
【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)
Leetcode 113. path sum II
Hcip eighth day experiment
uniapp处理后台传输图片
Programmer growth chapter 27: how to evaluate requirements priorities?
ES6数组去重 new Set()
How to solve the problem of taking up too much space when recording and editing videos?
若依如何实现用户免密登录配置方法?
hcip第十天笔记