|
|
вернуться в форумCOMPILATION ERROR in the Array declaration!!! can you please help me about what is wrong about this? You tried to solve problem 1161 Stripies. Your solution was compiled with the following errors: 93e006e3-949c-4a74-a88f-eb4b2c6dc082 93e006e3-949c-4a74-a88f-eb4b2c6dc082(19): error: expression must have a constant value int set[N]; ^ /* why can't I declare a new array like this? (N is integer) */ 93e006e3-949c-4a74-a88f-eb4b2c6dc082(61): error: expression must have a constant value int aux[max-min+1], i=min, k=0; ^ /* The same */ 93e006e3-949c-4a74-a88f-eb4b2c6dc082(61): error: expression must have a constant value int aux[max-min+1], i=min, k=0; ^ /* Two errors on the same line!!! */ compilation aborted for 93e006e3-949c-4a74-a88f-eb4b2c6dc082 (code 2) Re: COMPILATION ERROR in the Array declaration!!! You couldn't declare array with nonconstant value! In this case try to use dynamic array, or vector. int aux = new int[N]; or vector<int> aux(N); Re: COMPILATION ERROR in the Array declaration!!! Thaks for helping (I didn´t tried yet) But... does C (ANSI C, not C++) accept the "vector" type or "int a = new int[10]"??? I have solved dozens of problems using "int a[x];" at UVa online judge, I think there could be more reasonable to forbid the "vector" type using (not elemental) than "int a[x];" (ANSI C elemental array using) Thanks I hope your reply Sergio Ligregni, MEX Re: COMPILATION ERROR in the Array declaration!!! Sorry I've made a mistake... Not int aux = new int[N]; should be : int * aux = new int[N]; P.S. I don't know how to be with ANSI C, because I've never use it... P.P.S. I always use vector(or other STL containers). |
|
|