@yilingsama’:您的头文件呢。。
by 一心只读CSP @ 2020-01-25 13:13:40
@[一心只读CSP](/user/303246)
不好意思没有复制粘贴,```#include<stdio.h>
by yilingsama’ @ 2020-01-25 13:23:24
@[yilingsama’](/user/290936) main函数的类型呢
by CSP_Sept @ 2020-01-25 13:26:28
@[yilingsama’](/user/290936) 有可能出现有两个月同时不够钱
所以if(have<0)后
要输出-month
直接return 0;
不需要接下来的步骤了
by XQLG @ 2020-01-25 13:26:50
@[XQLG](/user/63394) 是用break吗?但是如果用break的话,输入到那里应该直接终止了,和那个输入格式不符了可能。
by yilingsama’ @ 2020-01-25 13:32:18
@[yilingsama’](/user/290936) 不用管输入格式,评测机是用文本输入的,不需要管她
by XQLG @ 2020-01-25 13:33:21
就是按照他的样例,-month是对的,但是第二个样例输出的不是1580而是1579,我怀疑是数据格式转换出现了问题,但我还是不会。。。真是谢谢各位了,麻烦你们了,新年快乐
by yilingsama’ @ 2020-01-25 13:34:32
@[XQLG](/user/63394) 好的,谢谢,我试试看
by yilingsama’ @ 2020-01-25 13:34:58
@[CSP_Sept](/user/224931) emm。。。我补上去,谢谢提醒,以前没这习惯
by yilingsama’ @ 2020-01-25 13:35:50
@[yilingsama’](/user/290936)
```
#include<stdio.h>
int main(){//C++不允许主函数没有类型
int month;
int have=0;
int store=0;
int pre;
int temp=13;
int integer;
int sum;
for(month=1;month<=12;month++){
have+=300;
scanf("%d",&pre);
have=have-pre;
if(have<0)
{
printf("%d\n",-month);
return 0;//这里直接返回,因为题目要求是第一个不够用的月份。
}
else
{integer=have/100*100;
store=store+integer;
have=have-integer;}
}
sum=(have+(store*1.2));
printf("%d",sum);
return 0;
}
```
by zhy137036 @ 2020-01-25 14:15:29