Computer Science Canada Times table 2 |
Author: | Jessica359 [ Fri Apr 11, 2008 9:31 am ] | ||
Post subject: | Times table 2 | ||
Just to add on to the times table,this is it finished but we need it to be in a straightline. How can i do that?
thnxs ![]() |
Author: | andrew. [ Fri Apr 11, 2008 9:44 am ] |
Post subject: | Re: Times table 2 |
Use colons instead of spaces in the put command. |
Author: | gitoxa [ Fri Apr 11, 2008 9:45 am ] |
Post subject: | Re: Times table 2 |
You do realize everything you just did it do-able in 7 lines? |
Author: | Tallguy [ Fri Apr 11, 2008 9:59 am ] |
Post subject: | RE:Times table 2 |
i have to know the same thing jess, check out my times table (the topic is called 'times table'), i need help too |
Author: | Jessica359 [ Fri Apr 11, 2008 10:47 am ] |
Post subject: | RE:Times table 2 |
in 7 lines...? seriously? |
Author: | StealthArcher [ Fri Apr 11, 2008 10:53 am ] |
Post subject: | RE:Times table 2 |
Yes, completely possible and easily done: 1. Think for loop, plus locate. 2. You can use a for loops number to multiply your root. 3. Using two for loops, you can use locate to set a row, and column. Think and read the helps, try it than come back. |
Author: | gitoxa [ Fri Apr 11, 2008 11:05 am ] |
Post subject: | Re: Times table 2 |
Using locate just makes things complicated. Field width is a good solution, but try using it on the numbers, rather then adding spaces. But to correct myself, 11 lines, not 7. I had it written in 7, but it wasn't quite right. Other than that... Nested loops; loops within loops. |
Author: | StealthArcher [ Fri Apr 11, 2008 11:07 am ] | ||
Post subject: | Re: Times table 2 | ||
6 lines, booyah |
Author: | Jessica359 [ Fri Apr 11, 2008 12:59 pm ] |
Post subject: | RE:Times table 2 |
awesome thanks ![]() |
Author: | Jessica359 [ Fri Apr 11, 2008 1:14 pm ] |
Post subject: | RE:Times table 2 |
WAIT! One problem... we need to use arrays for our program. |
Author: | gitoxa [ Fri Apr 11, 2008 1:14 pm ] |
Post subject: | Re: Times table 2 |
Where's your 1 times table? And the whole point was to get them to do the work theirselves, not do it for them. |
Author: | Jessica359 [ Fri Apr 11, 2008 1:24 pm ] |
Post subject: | RE:Times table 2 |
it doesn't matter if we get them to do it themselves or display them on the screen, it just has to be done with arrays and needs to be in straight colums and rows, i was told to use if statements but it takes 4ever to rearrange them all in straight lines, so ya.. ![]() |
Author: | CodeMonkey2000 [ Fri Apr 11, 2008 1:40 pm ] |
Post subject: | RE:Times table 2 |
You have to use arrays? This is a stupid assignment. A lot of assignments I see seem pretty stupid and pointless. This isn't even a practical application of arrays. It makes your code redundant. |
Author: | Sean [ Fri Apr 11, 2008 3:37 pm ] |
Post subject: | Re: Times table 2 |
Arrays should not be used for multiplication tables, regardless of what the teacher says. What you are doing is using ranges from 1 - 13, the for loops do this more effectively. The arrays should be used when collecting data for the same variable, such as first names, there would be numerous of them, depending on how many you collect, and it stores each input to the variable. Tell your teacher, that for loops are better then arrays in this situation, and see if the requirements can be modified. |
Author: | Jessica359 [ Fri Apr 11, 2008 6:14 pm ] |
Post subject: | RE:Times table 2 |
Ok i'll mention it to him. I know the assignments are stupid and pointless but hey if thats what he wants for a passing mark then thats what we have to give him. thnx though ![]() |
Author: | A.J [ Fri Apr 11, 2008 7:54 pm ] | ||
Post subject: | Re: Times table 2 | ||
make a 2-D array to store the times table of all numbers from 1..12 like this:
then, you can just use the locate thing again but this time it gets easier: since you're dealing with arrays, you can just use a for loop or a variable to keep track of the ith component of timestable(i,j), sine j just ranges from 1..12 ! sry if I was late ![]() |
Author: | CodeMonkey2000 [ Fri Apr 11, 2008 9:30 pm ] | ||||
Post subject: | Re: Times table 2 | ||||
Bah single dimensional array enables you to be more 1337.
EDIT: This program can be done in 4 lines.
|
Author: | OneOffDriveByPoster [ Fri Apr 11, 2008 10:44 pm ] |
Post subject: | Re: Times table 2 |
CodeMonkey2000 @ Fri Apr 11, 2008 9:30 pm wrote: Bah single dimensional array enables you to be more 1337. 1337-ness shouldn't be the point. This can help you avoid having arrays of pointers for dynamic 2-D arrays in C/C++. |
Author: | CodeMonkey2000 [ Fri Apr 11, 2008 10:55 pm ] | ||
Post subject: | RE:Times table 2 | ||
I never use multidimensional dynamic arrays. I always represent my data in a single dimensional array, it makes it easier to manage and clean up. EDIT: The whole thing in 8 lines, still trying to get it in 7 ![]()
|
Author: | gitoxa [ Sat Apr 12, 2008 12:04 am ] |
Post subject: | Re: Times table 2 |
Just use one for loop. ![]() |