I know that you have completed the program already, but I would like to promote simpler and nice programming techniques, so here's my take on the program. You input the string, and then press a key to select which letter you want to guess, and then press enter to show which ones are selected. It's just up to you know to display which ones have already been guessed... Which is relatively easy with this. Smile If you have MathPrint, I would suggest making it Classic. I probably am not going to explain this to much as it has already been uploaded, but it can be used for the future I guess. Hope this helps! Smile

I can explain it more, but it doesn't sound like you need it. Enjoy though! Smile

Code:
ClrHome
Input "",Str0
DelVar C" ->Str1:" "+Str0+" ->Str0
0->R
Repeat R
ClrHome
1->A:Ans->D:Ans->R
For(X,1,10
A+1->B
inString(Str0," ",Ans->A
If Ans:Then
Disp "
For(Z,1,A-B
sub(Str0,B+Z-1,1
If not(inString(Str1,Ans
Then:0->R:"-
End
Output(X,Z,Ans
End:Else
X->D
10->X:End:End
If R:Then
Pause "YOU WIN!
Else
Disp "ENTER GUESS:
0
Repeat Ans=105
Repeat Ans>40
getKey:End
If Ans!=105:Then
sub("ABC  DEFGHIJKLMNOPQRSTUVWXYZ      ",Ans-5int(.1Ans+4),1->Str2
Output(D+2,1,Ans:0:End
End
Str2+Str1->Str1
End
End:ClrHome


EDIT: Also, Haobo, this:

Code:
If L1(A)
Then
Output(A,1,sub(Str0,A,1))
Else
Output(A,1,"-")
End

Can be:

Code:
sub(Str0,A,1
If not(L1(A:"-
Output(A,1,Ans
Smile (I just really enjoy optimization, sorry. Smile )
How to do what? Are you trying to compare the different strings? If so, this is what I did for my game.

Code:
Input "",Str1
ClrHome
For(A,1,length(Str0))
inString(Str0," ",A)->B
If B!=0
Then
2->L1(B)
End
inString(Str0,Str1,A)->B
If B!=0
Then
1->L1(B)
End
A->C
If C>16
A-16iPart(A/16)->C
If L1(A)=0
Output(1+iPart((A-1)/16),C,"-")
If L1(A)=1
Output(1+iPart((A-1)/16),C,sub(Str0,A,1))
End

The A in the inString help so that all of the zeros are counted for. Rather long, but I hope that helps. If my program gets accepted, than you can always download the program and look at all of the code, as I do with all of my programs, to help better see the inner workings and understand what is happening.
Ummm.... Unless I am mistaken, my code is a complete hangman program that I made a while back... But that's just me. Razz
Mine is too. It looks like we just went along making them differently.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement