Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 name thing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Viper




PostPosted: Thu Sep 08, 2005 8:43 am   Post subject: name thing

A list of names is entered ending with the sentinel name "zzzz". Output each of the names not including the sentinel.
i cant have it not put the sentinel
Sponsor
Sponsor
Sponsor
sponsor
Flikerator




PostPosted: Thu Sep 08, 2005 10:29 am   Post subject: Re: name thing

Viper wrote:
A list of names is entered ending with the sentinel name "zzzz". Output each of the names not including the sentinel.
i cant have it not put the sentinel


All you have to do is is before you put the name, detect the "zzzz".

Depending on how you did it...

exit when name = "zzzz"
put name


(You in Mr.Cs class? Lolz )
Viper




PostPosted: Fri Sep 09, 2005 8:04 am   Post subject: (No subject)

tht dont work bc when they enter the name it puts it on the screen
Flikerator




PostPosted: Fri Sep 09, 2005 10:15 am   Post subject: (No subject)

Mind posting the code? It would be a lot easier to help you then.
beard0




PostPosted: Sun Sep 11, 2005 5:11 pm   Post subject: (No subject)

code:
View.Set ("noecho")
Token




PostPosted: Sun Sep 11, 2005 5:28 pm   Post subject: (No subject)

I dont think I understand the question, what do you mean by a sentinel? For some odd reason it comes to mind entering passwords when all you get is *** is that what we're trying to do here? I bet I'm completely off.
beard0




PostPosted: Sun Sep 11, 2005 5:37 pm   Post subject: (No subject)

The sentinel is the name being given to the string "zzzz"
Viper wrote:
...ending with the sentinel name "zzzz".

He need's to output all names except the sentinel, and so far has only managed to "output" every single name, by which I think he actually means that he let turing display them as he input them. What I was saying he should do is use View.Set("noecho") to surpress the display of input, and then actually output only those names that are not "zzzz."
[Gandalf]




PostPosted: Sun Sep 11, 2005 5:41 pm   Post subject: (No subject)

The difficulty in that is that then you don't see what you are typing. There is no way to see what you are typing, and not see when you type zzzz unless you want to ignore all z's or something?

Anyway, since I wanted to...
code:
View.Set ("noecho")
var name : flexible array 1 .. 0 of string
var cnt : int := 0

loop
    cnt += 1
    new name, upper (name) + 1
    get name (cnt)
    exit when name (cnt) = "zzzz"
    put name (cnt)
end loop
put "Finished"


Or a simplified version which doesn't store the names:
code:
View.Set ("noecho")
var name : string

loop
    get name
    exit when name = "zzzz"
    put name
end loop
put "Finished"
Sponsor
Sponsor
Sponsor
sponsor
beard0




PostPosted: Sun Sep 11, 2005 5:50 pm   Post subject: (No subject)

Okay, Gandalf

You can see what you type now:

Turing:
var name : flexible array 1 .. 0 of string
loop
    new name, upper (name) + 1
    get name (upper (name))
    exit when name (upper (name)) = "zzzz"
end loop
new name, upper (name) - 1
cls
for i : 1 .. upper (name)
    put name (i)
end for


P.S. Why the cnt?
[Gandalf]




PostPosted: Sun Sep 11, 2005 6:05 pm   Post subject: (No subject)

Oops Embarassed, it's not necessary, you're right.

I thought the problem was that the user shouldn't be able to see even when he is typing the zzzz. This would require the program to probably guess that when z is pressed it shouldn't output the name, which has quite a few problems.
beard0




PostPosted: Sun Sep 11, 2005 6:14 pm   Post subject: (No subject)

If you wanted to get really fancy, you could use getch, and output anything that could not be "zzzz" (ie, supress "z", but then if the user continues with "a", output "za" and everything that follows).
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: