arrays problem
Author |
Message |
_________
|
Posted: Wed May 18, 2011 8:48 am Post subject: arrays problem |
|
|
can someone help?
thanks for the help guys!
Create a program with the following code at the top:
var numbers:array 1 .. 10 of int:=init(2,7,3,7,9,4,1,8,9,6)
Your program must repeatedly ask the user for an index. The program must then create a new array, the size of which is the size of the old array minus one. The new array must contain every element of the old array except for the one at the entered index. The resulting new array should be shown, and the old array`s value should be re-set to the new array so that you may remove a new element from it.
The program must loop, so the second time that an index is asked for, the program must remove the next element from the newly created 9-element array. If the user enters an index higher than the size of the current array or less than 0, an error message must be displayed and you should ask again. If the user enters 0, or the array only has one element left, you should end the program.
Example:
Enter an index: 5
New array is: 2 7 3 7 4 1 8 9 6
Enter an index: 2
New array is: 2 3 7 4 1 8 9 6
Enter an index: 7
New array is: 2 3 7 4 1 8 6
Enter an index: 8
Index is too high. Try again.
Enter an index: 2
New array is: 2 7 4 1 8 6
...
Enter an index: 1
New array is: 7
Enter an index: 1
Array only has one element left.
What is the problem you are having?
<Answer Here>
Describe what you have tried to solve this problem
<Answer Here>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed May 18, 2011 10:00 am Post subject: RE:arrays problem |
|
|
so...
Quote:
What is the problem you are having?
<Answer Here>
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
mirhagk
|
Posted: Wed May 18, 2011 5:00 pm Post subject: RE:arrays problem |
|
|
Someone should update that form, so that if someone doesn't fill it out, it yells at them to actually state where their problem is.
Anyways, we need more info on where your stuck, what you've tried to do to fix it, what information you've searched, which search engine you've used to find your answer (if you haven't, don't worry, you can use mine, here http://www.google.ca) |
|
|
|
|
![](images/spacer.gif) |
_________
|
Posted: Fri May 20, 2011 8:13 am Post subject: Re: arrays problem |
|
|
i need help solving that question.
its for grade 10 computer science
ive tried to use flexible arrays, but im not sure how that works
i really dont know where to start |
|
|
|
|
![](images/spacer.gif) |
HRI
|
Posted: Fri May 20, 2011 8:16 am Post subject: RE:arrays problem |
|
|
Perhaps you should try the arrays tutorial. It talks about deleting an index and keeping the order of the array intact. |
|
|
|
|
![](images/spacer.gif) |
|
|