Computer Science Canada Hmm breaking strings |
Author: | MysticVegeta [ Fri Jan 21, 2005 5:19 pm ] |
Post subject: | Hmm breaking strings |
If I have a string i wanna break it by 2. What do i do? For eg: 1234567890 will result in 24680 see what i mean? |
Author: | Dan [ Fri Jan 21, 2005 5:24 pm ] | ||
Post subject: | |||
You need to use subtrings and a forloop that goes up by 2. example:
The i+1 is the index of the string, you need to add 1 b/c it whould give u the odd numbers other wise. The length function returns the number of chars in a string |
Author: | MysticVegeta [ Fri Jan 21, 2005 8:14 pm ] | ||
Post subject: | |||
Hacker Dan wrote: You need to use subtrings and a forloop that goes up by 2.
example:
The i+1 is the index of the string, you need to add 1 b/c it whould give u the odd numbers other wise. The length function returns the number of chars in a string oO I was having a simple error <_> i forgot +1 lol thanks a lot btw |
Author: | MysticVegeta [ Sat Jan 22, 2005 11:07 am ] | ||
Post subject: | |||
Uh yea i almost forgot, what if i have a string like this
How do i add 1+8 after breaking them? |
Author: | basketball4ever [ Sat Jan 22, 2005 11:31 am ] |
Post subject: | |
wat do u mean adding em....??? u really got to work on your english. |
Author: | Bacchus [ Sat Jan 22, 2005 12:28 pm ] | ||||
Post subject: | |||||
im guessing either added them to gether (18=1+8=9) or adding them back together (18=1+8=18) to do that: 1st one
2nd one
theres other ways but meh |
Author: | basketball4ever [ Sat Jan 22, 2005 12:33 pm ] |
Post subject: | |
i'm guessing the first one... cos theres no point in adding them back together i guess |
Author: | MysticVegeta [ Sat Jan 22, 2005 1:59 pm ] | ||||
Post subject: | |||||
Bacchus wrote: im guessing either added them to gether (18=1+8=9) or adding them back together (18=1+8=18) to do that:
1st one
2nd one
theres other ways but meh Ok , it works but what if i want to add strings stored in an array for eg: Number 1 -> 182345 Number 2 -> 870934 but i want the results to be 23 for number 1 31 for Number2 Does it mean i have to convert results into array too? and make 2 of them to make each of them store the total of one of the number? How do i do that? |
Author: | Bacchus [ Sat Jan 22, 2005 4:24 pm ] | ||
Post subject: | |||
|
Author: | basketball4ever [ Sat Jan 22, 2005 5:25 pm ] | ||
Post subject: | |||
Bacchus wrote:
Instead of intstr... it should be strint ur changing the original string to an int |
Author: | Bacchus [ Sat Jan 22, 2005 5:45 pm ] |
Post subject: | |
oops had it backwards, srry i was using intstr earlier and quite a bit of it |
Author: | basketball4ever [ Sat Jan 22, 2005 6:06 pm ] |
Post subject: | |
Bacchus wrote: oops had it backwards, srry i was using intstr earlier and quite a bit of it
no worries : P just trying to help out our non-english friend "mystic vegeta" here |
Author: | MysticVegeta [ Sat Jan 22, 2005 8:27 pm ] | ||
Post subject: | |||
Um incase you dont know, please read my question again, i am too advanced to point that strint thing out, i just looked at it and didnt bother to waste time on posting that... i just changed it when i was using it. Oh yea. Incase you dont know, here is the problem i am trying to solve and here is the code i have for it so far, so i dont see the point of being non - english jackie. http://www.ldcsb.on.ca/schools/sta/DWITE/Problem1Nov2004.pdf
|
Author: | Cervantes [ Sat Jan 22, 2005 8:51 pm ] |
Post subject: | |
MysticVegeta wrote: i am too advanced to point that strint thing out
MysticVegeta wrote: I know that your level doesnt stand a chance against mine, Yes i am the one that taught your mom and dad how to program
You know, modesty is a good thing. |
Author: | MysticVegeta [ Sat Jan 22, 2005 9:39 pm ] |
Post subject: | |
Cervantes wrote: MysticVegeta wrote: i am too advanced to point that strint thing out
MysticVegeta wrote: I know that your level doesnt stand a chance against mine, Yes i am the one that taught your mom and dad how to program
You know, modesty is a good thing. I know man, I really do. But the thing is that basketball4ever is in my TIK class and always jealous and bothers me in every topic even tho i dont start the argument.... Ok anyways can you help me in my problem? |
Author: | Cervantes [ Sat Jan 22, 2005 10:07 pm ] |
Post subject: | |
I'd love to, but you're way too advanced for me. |
Author: | Bacchus [ Sat Jan 22, 2005 10:26 pm ] |
Post subject: | |
lol ur having quite a bit of fun arnt u |
Author: | MysticVegeta [ Sun Jan 23, 2005 12:04 am ] |
Post subject: | |
Cervantes wrote: I'd love to, but you're way too advanced for me.
yea pfft i am a newbie. Only in grade 9 |