//accepted
#include<iostream>
using namespace std;
int main()
{
int now[14],need[13],t=0,n,i,j;
while(cin>>n)
{
if(n<0)break;
now[0]=n;
for(i=1;i<=12;i++)
cin>>now[i];
for(j=0;j<12;j++)
cin>>need[j];
cout<<"Case "<<++t<<":\n";
for(i=0;i<12;i++)
{
// cout<<now[i]<<' '<<need[i]<<now[i]-need[i]<<' ';
if(now[i]-need[i]>=0)
{
now[i+1]=now[i+1]+now[i]-need[i];
cout<<"No problem! :D\n";
}
else
{
now[i+1]+=now[i];
cout<<"No problem. :(\n";
}
}
}
return 0;
}
What is the problem of my code??
ReplyDelete#include
#include
using namespace std;
int main()
{
int a[20],b[20],i=0,j,n;
while(cin>>n)
{
if(n<0)return 0;
a[0]=n;
for(int c=1;c<13;c++)
cin>>a[c];
for(int d=0;d<12;d++)
cin>>b[d];
printf("Case %d:\n",++i);
for(j=0;j<12;j++)
{
if(a[j]-b[j]>=0)
{
a[j+1]=a[j+1]+a[j]-b[j];
cout<<"No problem! :D"<<endl;
}
else
{
a[j+1]+=a[j];
cout<<"No problem! :("<<endl;
}
}
}
return 0;
}