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

Username:   Password: 
 RegisterRegister   
 Shortening this code? or easier to write it?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SpaceDude




PostPosted: Tue Jun 08, 2004 8:23 pm   Post subject: Shortening this code? or easier to write it?

anyone know how i can shorten this code up? or write it easier?

code:
var Names : array 1..100  of string

Names (1) := "Bob"
Names (2) := "Albert"
Names (3) := "Patrick"
.
.
.
.
.
Names (98) := "Sam"
Names (99) := "Thomas"
Names (100) := "Raymond"
Sponsor
Sponsor
Sponsor
sponsor
aside




PostPosted: Tue Jun 08, 2004 8:46 pm   Post subject: (No subject)

you can store the names in a file and call it, then use get with your variables.
SpaceDude




PostPosted: Tue Jun 08, 2004 8:49 pm   Post subject: (No subject)

what if it has to be all done in one turing file, like no side files and etc?
aside




PostPosted: Tue Jun 08, 2004 8:51 pm   Post subject: (No subject)

well, you can simplify it a little by this:
code:

var names: array 1..100 of int :=init("bob", "mjkjk", ...."kdj")

and why does it have to be done in one file?
SpaceDude




PostPosted: Tue Jun 08, 2004 8:53 pm   Post subject: (No subject)

cuz is a project lol, i have to submit it, so basically it has to be all done in this turing file and no sidefiles
aside




PostPosted: Tue Jun 08, 2004 8:56 pm   Post subject: (No subject)

well, that's just stupid. and why do you need all these names?
anyway, ignore me.
SpaceDude




PostPosted: Tue Jun 08, 2004 8:57 pm   Post subject: (No subject)

o the file is similar to this is not the same though lol

so basically there is no other way to shorten this code up?
aside




PostPosted: Tue Jun 08, 2004 9:01 pm   Post subject: (No subject)

well, you have to include all the names somehow, think about it, it is already simple enough.
SpaceDude




PostPosted: Tue Jun 08, 2004 9:11 pm   Post subject: (No subject)

i guess lol thanks
if any 1 else have any ideas or suggestions just post it here i wanna see if there is other ways, cuz it is very very long lol
Tony




PostPosted: Tue Jun 08, 2004 9:47 pm   Post subject: (No subject)

random name generation! Laughing
code:

function randomName () : string
    const v : string := "aeiouy"
    const c : string := "bcdfghjklmnpqrstvwxz"
    var r1, r2, r3 : int
    r1 := Rand.Int (1, length (c))
    r2 := Rand.Int (1, length (v))
    r3 := Rand.Int (1, length (c))
    result c (r1) + v (r2) + c (r3)
end randomName

for i : 1 .. 10
    put randomName ()
end for
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SpaceDude




PostPosted: Wed Jun 09, 2004 12:02 am   Post subject: (No subject)

lol tahts pretty amazing lol
but their not really names lol
Tony




PostPosted: Wed Jun 09, 2004 2:34 pm   Post subject: (No subject)

i'm sorry, but that's as close as you can get to real names without the use of any kind of external dictionary... Some names generated are preaty good actually Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SpaceDude




PostPosted: Wed Jun 09, 2004 3:09 pm   Post subject: (No subject)

lol ic
i guess so lol
Paul




PostPosted: Thu Jun 10, 2004 6:27 pm   Post subject: (No subject)

Just get one of those name lists, put it into a text file, then load them up into an array using a loop, and randomly choose some names.
naoki




PostPosted: Fri Jun 25, 2004 4:25 pm   Post subject: (No subject)

apprently, either spacedude sucks or whoever's teaching him sucks

why in god's name would a teacher demand 100 names from a student, without the use of textfiles, and won't accept anything with improv like random name generation?

now, you could do something like whenever you take a name, and put it into an array, take the next array space, and using the same name, catenate "ina" to the end, to make it seem like a girls

code:

for x : 1 .. 100 by 2
      put "input a name"
      get name : *
       namelist (x) := name
      namelist (x+1) := name + "ina"
end for
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 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: