Constructing an array

If I have an existing array a, and an integer k, how do I create an array such that the i-k to i+k th positions must have exactly a[i] elements smaller than a[i]

This array must be the smallest possible array
If I have an existing array a, and an integer k, how do I create an array such that the i-k to i+k th positions must have exactly a[i] elements smaller than a[i]


What is i?
Hello okfree,

Since you are fairly new here these links should help http://www.catb.org/esr/faqs/smart-questions.html

And

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

I found the second lint to be the most help.

"hoogo" asked a fair question and appears to have been reported for it. Not the way to get an answer to your questions.

Like "hoogo" I have to ask what is "k" and what is its intended use? How do you intend to use it?

The same goes for "i". Where did it come from? And how does it get its value?

With out any code to see what you have attempted they are both fair questions.

If "k" is used to determine the size of the array I can tell you that int a[k]; will not work because "k" needs to be a constant value. Whether "k" is defined as a constant or an actual number is used it must be a constant. I am not up on all the C++ specifications, but I believe that form C++98 on the size of an array must be known at compile time so the compiler can set aside the proper amount of space for the array on the stack. The use of a variable may be allowed in C++17, but I do not know.

"i" is generally used as the loop counter of a for loop along with the letters "j" and "k" which makes the use of "k" questionable.

In your question i-k to i+k th positions is confusing. At first look I would say that either side of "to" could put you outside the boundaries of the array which would cause the program to crash at run time.

And the part a[i] elements smaller than a[i] makes no sense. If "s[i]" has a value of 10 it would read 10 elements smaller than 10. What is the real meaning?

If you have some code post it even if you think it is wrong. It may not be as bad as you believe.

If you intend to report everyone that asks questions to try to help you. You are likely to find that no one is likely to work on this.

Hope that helps,

Andy
I didn't report him!

i refers to an index

k helps to establish a range(has to remain within bounds)

>And the part a[i] elements smaller than a[i] makes no sense. If "s[i]" has a value of 10 it would read 10 elements smaller than 10. What is the real meaning?

There needs to be 10 elements smaller than the b[i]th position in this case, within the range established via k
There's some weird "reporting" going on. Best to just ignore it.
I'm a little confused by what your asking...
If by i you mean the index and the number of elements, then I follow. Is there an original problem statement? Post that and some code
Topic archived. No new replies allowed.