Need help with assignment
Author |
Message |
Michael
|
Posted: Wed Nov 02, 2005 9:31 am Post subject: Need help with assignment |
|
|
Hey people this is my first post.
First let me introduce my self.. my name is Michael I'm a grade 10 student and we use turing at school.
I'm way a head of my class and I got to these 2 problems:
Write a program for the following problems. Please follow the I-P-O setup in order to solve the problems.
1. Write a program which will ask the user to enter a four digit number such as 1234 and have it output 4321.
2. Write a program that output the following pattern.
0 1 2 3 4 5
1 2 3 4 5 6
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
5 6 7 8 9 10
I have no idea how do it... i know it has to do something with loops but other than that no idea
Thanks for your help |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Wed Nov 02, 2005 9:47 am Post subject: Re: Need help with assignment |
|
|
Hello, Michael. Welcome. First thing you ought to know is that we dont do assignments here, we help students with their coding. So what happens is you post what code you have and we help you solve it, not do it for you. So what you need to do is get a start on this 'assignment' and we can help you along the way.
Second thing, is it just me, or does this not make any sense . .
Michael wrote: I'm way a head of my class and I got to these 2 problems:
What you can do to get started is look under Turing Help (F10 in Turing) and look up "for loops", they will be very useful for you.
The next thing you can look up is strings, and how to convert an integer int a string ("intstr"). So basically what the format to your first question would be is
code: |
var reverse :string := ""
var number:int
get number
%convert number into "reverse" variable (intstr)
for decreasing . . . . and whatnot (look that up)
reverse += . . . . (try that out)
end for
put reverse |
Once you have this program down, your next one should be easier to do.
Good luck. |
|
|
|
|
![](images/spacer.gif) |
Flikerator
|
Posted: Wed Nov 02, 2005 11:17 am Post subject: (No subject) |
|
|
Snip!
If you want to know what it does take it apart, and use the turing help files. |
|
|
|
|
![](images/spacer.gif) |
xXInsanityXx
![](http://www.animationlibrary.com/Animation11/Jobs_and_People/Computer_Programmers/programmer_2.gif)
|
Posted: Wed Nov 02, 2005 9:42 pm Post subject: (No subject) |
|
|
Snip!
That was for your first question... that works for more than 4 digits, and letters. Does this have to be only integer? Please specify, and i dont understand your second question... please explain it again. Thank you |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Thu Nov 03, 2005 7:05 am Post subject: (No subject) |
|
|
Wow guys, so much for that whole, "we dont do your assignments" thing, eh? Any dough brain can say what the answer is, in order to learn you need to try it out for yourself. (Thats why teachers give out homework).
Mod edit: On the off chance that Michael hasn't read these posts yet, answers have been removed. |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Thu Nov 03, 2005 7:36 pm Post subject: (No subject) |
|
|
This brings me to the point, I wish they had Str.Reverse command, is it in Stargate's thing for list of commands? |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Thu Nov 03, 2005 11:24 pm Post subject: (No subject) |
|
|
Not really, it's not really a useful function, you would just be doing the work for someone on an assignment. They would never again use that function. That is the problem I started seeing with that 'project', a lot of the input was just showy random stuff that doesn't really have a purpose. |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Fri Nov 04, 2005 6:09 pm Post subject: (No subject) |
|
|
not useful?! what about conditions when checking for palindromes?
instead of a loop and extra var, 1 line does it all! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Fri Nov 04, 2005 7:44 pm Post subject: (No subject) |
|
|
Ok, that's one... There are very few uses for such a function, not too many problems make use of something like that. |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Fri Nov 04, 2005 7:56 pm Post subject: (No subject) |
|
|
MysticVegeta wrote: not useful?! what about conditions when checking for palindromes?
instead of a loop and extra var, 1 line does it all!
Checking for a palindrome is not all that useful...
But anyways, I think I covered it in my string module. It's in that thread. |
|
|
|
|
![](images/spacer.gif) |
|
|