#include "iostream" using namespace std;

int main() { int budget[12]; for (int i = 0; i < 12; i++) { cin >> budget[i]; }

int saved = 0;  // 平常存的钱 
int month = 0;  // 出现钱不够用的月份 

for (int i = 0; i < 12; i++) { 
    saved += 300;  // 每个月妈妈给的零花钱 

    if (saved < budget[i]) { 
        month = -(i + 1);  // 出现钱不够用的月份 
        break; 
    } 

    saved -= budget[i];  // 扣除本月花销 
    int remainder = saved % 100;  // 计算余额 

    if (remainder >= 100) { 
        saved -= remainder;  // 存整百的钱 
    } 
} 

if (month != 0) { 
    cout << month << endl; 
} else { 
    saved += saved * 0.2;  // 年末妈妈加上20%还给津津 
    cout << saved << endl; 
} 

return 0; 

}

津津的储蓄计划:C++代码实现及SEO优化

原文地址: https://www.cveoy.top/t/topic/qtBr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录