ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1161. Stripies

COMPILATION ERROR in the Array declaration!!!
Послано Sergio Ligregni 29 янв 2008 10:16
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!!!
Послано Romko [Lviv NU] 29 янв 2008 20:22
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!!!
Послано Sergio Ligregni 30 янв 2008 10:27
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!!!
Послано Romko [Lviv NU] 31 янв 2008 01:26
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).