Hi there.
Well, as far as I can see, there are a lot of basic concepts you would have to learn before trying to write a program like that. What I know is from the C languaje, but it is also useful for this case.
First: The 'i' index initialization in the 'for' loop ---> You initilalized 'i = 1', therefore ignoring the first element of 's', which is s[0].
Second: temp value assignation and k vector---> you defined an array of integers called 'k', but you never gave any value to it's elements. You should know that the C preprocessor evaluates statemets in a certain order, according to their "weight" in C syntax. In this case, when you write 'temp = k', the preprocessor evaluates the statement from right to left. In other words, it takes the value of 'k' and assignes it to the variable 'temp'. As you never assigned any value to k before that, you're basically giving junk code to temp.
Third: Printing results ---> The "printf( "%d\n", k );" statement is wrong. I think this may be the cause of that 543054569 or somethig number that showed up. 'k' is only a pointer to the first element of the array, this means that you're actually printing a memory adress. If you want to print the elements of an array, you must define an index, let's say 'n' f.e., and print each element of the array in increasing order, until reaching its dimension.
int array[10];
int n;
for( n = 0; n < 10; n++ )
printf( "%d\n", array[i] );
I personally think the code you're trying to write is out of league for the moment. You should focus on the mentioned details first.
I wrote a version of the program in C. I don't know if you'll understand it right now, but I hope it is useful to you in the future, when you have a better knowledge of the subject in matter.
This was my first reply since I registered in this forum, so I hope I helped you bit.
If you have any questions, please don't mind asking them.
Cheers.