|
|
back to boardTest 3 WRONG Posted by Fspace 6 Nov 2013 20:52 #include <iostream> using namespace std; int main() { int k,n,l=1; int r=0; int* a = new int[1]; cin >> k >> n; cin >> a[0]; for(int i=1;cin >> a[i];i++) l+=1; for(int i=0;i<n;i++){ if(i<l) r+=a[i]; r-=k; if(r<0) r=0; } cout << r << endl; system("pause"); return 0; } Что не так? Edited by author 06.11.2013 23:12 Re: Test 3 WRONG Posted by Noob 6 Nov 2013 22:29 int* a = new int[1]; LOLWUT? Re: Test 3 WRONG Posted by Fspace 6 Nov 2013 23:09 This is a dynamic array. The number in [] has no importance. An array is okay Edited by author 06.11.2013 23:14 Re: Test 3 WRONG Posted by Leonid 7 Nov 2013 00:29 Re: Test 3 WRONG Posted by Fspace 7 Nov 2013 11:02 All right. Thanks for the information. But I find it hard to understand how I should use it in the program. Please correct my code .. Re: Test 3 WRONG Posted by Leonid 7 Nov 2013 12:28 In this case, just don't use pointers. You can declare an array using following syntax: Typename variableName[ arraySize ]; Exapmle: int array[ 100 ]; In this example, an array of 100 int elements will be created. I suppose, that most of problems from archive can be solved without using dynamic memory allocation. Edited by author 07.11.2013 12:30 Re: Test 3 WRONG Posted by Fspace 7 Nov 2013 16:05 Thanks for the help Re: Test 3 WRONG Posted by Logan`~ 14 Sep 2018 20:33 попробуйте 5 5 0 0 0 0 0 |
|
|