Author |
Message |
jhdho0204
|
Posted: Thu Dec 09, 2010 6:06 pm Post subject: Could anyone help please? |
|
|
What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
Let n be a positive integer consisting of the digits dk?d1d0. Write a program that reads in a value of n and then prints its digits in a column, start with d0. Fro example if n = 3467, then the program should print
7
6
4
3
What is the problem you are having?
<Answer Here>
Describe what you have tried to solve this problem
<Answer Here>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
<Answer Here>
This is the question i got a problem with.. could someone help? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Thu Dec 09, 2010 6:14 pm Post subject: RE:Could anyone help please? |
|
|
What kind of a problem do you have with this question? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
jhdho0204
|
Posted: Fri Dec 10, 2010 9:57 am Post subject: RE:Could anyone help please? |
|
|
I have problem with coding.. I'm not sure... could someone type in a code for me or something? |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Fri Dec 10, 2010 10:31 am Post subject: RE:Could anyone help please? |
|
|
Of course you're having a problem with your coding. If you were having issues with your breakfast, you wouldn't be here would you?
We're not writing even a single line for you though. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Dec 10, 2010 12:38 pm Post subject: RE:Could anyone help please? |
|
|
@jhdho0204: I'm sure that you are able to solve this question. If n=1234, describe, step by step, how you would get the answer. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
jhdho0204
|
Posted: Fri Dec 10, 2010 6:37 pm Post subject: RE:Could anyone help please? |
|
|
Well my code is:
var n: int
put "Type in an integer: "..
get n
for 1.. n
n mod 2= 1
put n
end for |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Fri Dec 10, 2010 6:50 pm Post subject: RE:Could anyone help please? |
|
|
Quote: n mod 2 = 1
You're not even trying. This doesn't do anything. I'm not sure if this will even compile.
Mathematically, how do you get the least significant digit in a number? The second least? Once you figure that out, it's a walk in the park to output it.
Here's a hint: You CAN (and probably should) use modulus. |
|
|
|
|
![](images/spacer.gif) |
Searing
|
Posted: Tue Dec 14, 2010 10:34 am Post subject: Re: Could anyone help please? |
|
|
Or you could get the number as a string instead of an integer.
var num: string
Then use string operations to get the result you want. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|