|
|
back to boardwhat is wrong? Posted by Stan 19 Nov 2015 19:56 #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char *argv[]) { int k,n,i; cin>>k>>n; int y[n+1]; for (i=1;i<=n;++i) { cin>>y[i]; } for (i=1;i<=n;++i) { if (y[i]>k) {y[i+1]+=y[i]-k;} else {y[i]=0;} } cout<<y[n+1]<<endl; return 0; } |
|
|