|
|
вернуться в форумComplication error? In Dev it works... #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { int a; cin>>a; int b; cin>>b; int c; int tab[b]; for(int i=0; i<b; i++) { cin>>tab[i]; } for (int j=1; j<b; j++) { if (tab[j-1]-a<0) tab[j]=tab[j]; else tab[j]=tab[j]+(tab[j-1]-a);
} if (tab[b-1]-a<0) cout<<"0"<<endl; else cout<<(tab[b-1]-a)<<endl; system("PAUSE"); return EXIT_SUCCESS; } In dev-c++ it works... Edited by author 11.07.2012 19:10 Re: Complication error? In Dev it works... Error in this line int tab[b]; Array size should be constant value. Re: Complication error? In Dev it works... The problem is that compiler on this website(Visual C++) has a little another syntax and you can't use such thing: int b; cin>>b; int tab[b]; An array size in C++ must be initialized by a constant value, so you can't initialize it by a variable you read from the stream. Try use dynamic arrays in such cases. Edited by author 12.07.2012 13:50 |
|
|