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