Re: array of booleans
- From: zero <zero@xxxxxxx>
- Date: Sat, 01 Oct 2005 17:29:55 GMT
zeus2@xxxxxxxxxxx wrote in news:1128145921.794117.187320
@g49g2000cwa.googlegroups.com:
> perahps this sample output might help. I have an array for the votes,
> however, when no NUMERIC vote is entered, i want to be able to default
> the lowest number, 1,2 in this case for the votes that have not been
> physically entered. Don't i need to store it in an array? Some
> pseudocode would be helpful in breaking the problem down..
>
> cheers...peri
>
> Please enter the next vote
> Ballot paper 1
> Please enter the next vote (for Brad): 3
> Please enter the next vote (for Candidate 2): <---no vote(defaults 1)
> Please enter the next vote (for Julian): <---no vote(defaults 2)
> Please enter the next vote (for Rob): 4
> Please enter the next vote (for Ian): 5
> (E)nter or (R)eset ballot paper: e
> Vote 1 entered; Please enter the next vote
> Do you have more ballot papers to enter (Y/N): n
>
>
I don't think you need an array of booleans here. You just keep track of
what the current lowest number is, and if nothing was entered, you use
this lowest number.
in pseudo code:
initialize lowestInt to 1
read the input
if input is not an integer
{
value = lowestInt
lowestInt++
}
else
value = input
use value
Note that this does not account for the user entering 1 on the first
line, then nothing on the second. In this case you'll have 1 for both
votes.
.
- References:
- array of booleans
- From: zeus2
- array of booleans
- Prev by Date: Re: Under Linux, Call java from C++
- Next by Date: Re: Under Linux, Call java from C++
- Previous by thread: Re: array of booleans
- Next by thread: Re: executeQuery() - How many SQL statements allowed?
- Index(es):
Relevant Pages
|