• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 01:25
CEST 07:25
KST 14:25
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL19Code S RO12 Preview: Cure, Zoun, Solar, Creator4[ASL19] Finals Preview: Daunting Task30[ASL19] Ro4 Recap : The Peak15
Community News
Weekly Cups (May 19-25): Hindsight is 20/20?0DreamHack Dallas 2025 - Official Replay Pack8[BSL20] RO20 Group Stage2EWC 2025 Regional Qualifiers (May 28-June 1)17Weekly Cups (May 12-18): Clem sweeps WardiTV May3
StarCraft 2
General
Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN Can anyone explain to me why u cant veto a matchup The Memories We Share - Facing the Final(?) GSL Karma, Domino Effect, and how it relates to SC2. Code S RO12 Preview: Cure, Zoun, Solar, Creator
Tourneys
[GSL 2025] Code S:Season 2 - RO12 - Group B EWC 2025 Regional Qualifiers (May 28-June 1) DreamHack Dallas 2025 [GSL 2025] Code S:Season 2 - RO12 - Group A RSL: Revival, a new crowdfunded tournament series
Strategy
Connect with Key Decision-Makers Through Ready Mai Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 475 Hard Target Mutation # 474 Futile Resistance Mutation # 473 Cold is the Void Mutation # 472 Dead Heat
Brood War
General
Will foreigners ever be able to challenge Koreans? BGH auto balance -> http://bghmmr.eu/ Battle.net is not working BW General Discussion Practice Partners (Official)
Tourneys
[ASL19] Grand Finals [BSL20] RO20 Group D - Sunday 20:00 CET [BSL20] RO20 Group B - Saturday 20:00 CET Small VOD Thread 2.0
Strategy
I am doing this better than progamers do. [G] How to get started on ladder as a new Z player
Other Games
General Games
Path of Exile Nintendo Switch Thread Monster Hunter Wilds Beyond All Reason Battle Aces/David Kim RTS Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
Heroes of the Storm
Simple Questions, Simple Answers
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia TL Mafia Community Thread TL Mafia Plays: Diplomacy TL Mafia: Generative Agents Showdown Survivor II: The Amazon
Community
General
Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine US Politics Mega-thread All you football fans (soccer)! European Politico-economics QA Mega-thread
Fan Clubs
Serral Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion!
Sports
2024 - 2025 Football Thread NHL Playoffs 2024 Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Cleaning My Mechanical Keyboard How to clean a TTe Thermaltake keyboard?
TL Community
The Automated Ban List TL.net Ten Commandments
Blogs
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Yes Sir! How Commanding Impr…
TrAiDoS
Poker
Nebuchad
Info SLEgma_12
SLEgma_12
SECOND COMMING
XenOsky
WombaT’s Old BW Terran Theme …
WombaT
Customize Sidebar...

Website Feedback

Closed Threads



Active: 23195 users

help with computing algorithms!

Blogs > GTR-2-Go
Post a Reply
GTR
Profile Blog Joined September 2004
51411 Posts
Last Edited: 2008-06-01 09:55:31
June 01 2008 09:52 GMT
#1
any programmers out there? i have an algorithm assignment and i'm kind of having troubles understanding some of it, yes it is easy but i ain't really a pro at this stuff

1)
Begin
  get Num (an integer) from user
  set Count to 0
  While Count < Num
    set Temp to Count + 1
    print Temp
    increment Count
  Endwhile
  Print Count
End

What is the output after the users enter a value of 3 - I assume it is 3?
"" value of -1 - Nothing right? Since the Num is greater than the count.

2)
Begin
  read A
  While A > 0
    set Answer to 'No'
    If A > 8 Then
    set Answer to 'Yes'
  Endif
  print Answer
  Read A
  EndWhile
End

If 8, 3 then 0 were read in sequence, what would the output be - I have no idea what this means.

3) Write an algorithm in both psuedocode and flowchart that will print out the first 20 odd numbers.
Something simple I imagine, some sort of loop?

4) Write an algorithm in "" that will allow you to enter a student's name, enter 4 test marks out of 10 then print out the student's name and the average of the 4 tests.
I assume there will be an input, a loop for inputting marks and the print of the name and the mean of the marks?

help, i suck at this badly.

f

Commentator
BroOd
Profile Blog Joined April 2003
Austin10831 Posts
June 01 2008 10:16 GMT
#2
I hate you.
ModeratorSIRL and JLIG.
imDerek
Profile Blog Joined August 2007
United States1944 Posts
June 01 2008 10:24 GMT
#3
algorithm 1 prints all the positive integers less than or equal to the input, then print the input itself (cus of the "Print Count" after the while loop) ,so if you input 3, you get 1 2 3 3. If you input -1, you get -1
Least favorite progamers: Leta, Zero, Mind, Shine, free, really <-- newly added
GTR
Profile Blog Joined September 2004
51411 Posts
June 01 2008 10:44 GMT
#4
On June 01 2008 19:24 imDerek wrote:
algorithm 1 prints all the positive integers less than or equal to the input, then print the input itself (cus of the "Print Count" after the while loop) ,so if you input 3, you get 1 2 3 3. If you input -1, you get -1


if you inputted -1 wouldn't it be just a print count of 0 because if the count is set to 0, the loop is skipped since your number is -1?
Commentator
stenole
Profile Blog Joined April 2004
Norway868 Posts
June 01 2008 10:54 GMT
#5
Insead of dumping your entire homework into your blog, why don't you just specifically tell us what you are having trouble with. And like you pointed out, input of -1 gives output of 0, because that is what the count variable was initiated as and it hasnt been changed.
zatic
Profile Blog Joined September 2007
Zurich15324 Posts
Last Edited: 2008-06-01 11:01:59
June 01 2008 10:57 GMT
#6
3)
i = 1
while i < 42
print i
increment i by 2
ModeratorI know Teamliquid is known as a massive building
Bockit
Profile Blog Joined November 2004
Sydney2287 Posts
Last Edited: 2008-06-01 11:01:42
June 01 2008 11:01 GMT
#7
Us telling you the output isn't gonna help you out much.

My suggestion if you are having trouble is to do a desk check, i.e. go through the algorithm step by step and write down the variables and their values at each point, and any output the algorithm generates.
Their are four errors in this sentance.
imDerek
Profile Blog Joined August 2007
United States1944 Posts
June 01 2008 11:02 GMT
#8
On June 01 2008 19:44 GTR-2-Go wrote:
Show nested quote +
On June 01 2008 19:24 imDerek wrote:
algorithm 1 prints all the positive integers less than or equal to the input, then print the input itself (cus of the "Print Count" after the while loop) ,so if you input 3, you get 1 2 3 3. If you input -1, you get -1


if you inputted -1 wouldn't it be just a print count of 0 because if the count is set to 0, the loop is skipped since your number is -1?


right, sorry bout that
Least favorite progamers: Leta, Zero, Mind, Shine, free, really <-- newly added
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 01 2008 11:33 GMT
#9
For number 3, in scheme:

STk> (define (waa)
(define (wee x)
(if (= x 20)
nil
(cons (+ 1 (* 2 x)) (wee (+ x 1)))))
(wee 0))
waa

STk> (waa)
(1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39)

I'll explain:
(waa) is a loop, it basically runs another recursive function w/ input of 1, this function is called wee

How wee work:
wee is a function that takes input, that are actually indexes of the odd number, 1 would be indexed 0, 3 is 1, 5 is 2 on the index, and so on...

if input=20, gives nothing, so it terminates.
if input<20, add to the front of the array (2*input + 1), the corresponding odd number to the index, and recursively construct the rest of the array with input+1, the next index.

I dunno if its clear ~~
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
GTR
Profile Blog Joined September 2004
51411 Posts
June 01 2008 11:41 GMT
#10
Alright, did this finally, just used some help from a programming friend (hi stenole).

Thanks for the help.
Commentator
stenole
Profile Blog Joined April 2004
Norway868 Posts
June 01 2008 12:10 GMT
#11
On June 01 2008 20:33 evanthebouncy! wrote:
I'll explain:
(waa) is a loop, it basically runs another recursive function w/ input of 1, this function is called wee

If we ever worked on a programming project together, I would probably have to kill you. wee and waa are not good names for things unless you are trying to make code unreadable on purpose.
Lisk
Profile Blog Joined May 2006
Latvia376 Posts
June 01 2008 14:38 GMT
#12
Wow, I just can't read without () and {} ...
boss420
Profile Blog Joined March 2008
Cyprus109 Posts
June 01 2008 15:08 GMT
#13
<br>hi</br>

coding pro right here
micronesia
Profile Blog Joined July 2006
United States24637 Posts
June 01 2008 17:28 GMT
#14
void isgtrgay()
{
char gtrgay='y';
while (gtrgay=='y')
{
cout << "GTR is gay for that match last night!\n";
}
return;
}
ModeratorThere are animal crackers for people and there are people crackers for animals.
tec27
Profile Blog Joined June 2004
United States3696 Posts
Last Edited: 2008-06-01 19:01:09
June 01 2008 19:00 GMT
#15
On June 02 2008 00:08 boss420 wrote:
<br>hi</br>

coding pro right here

You can't close a break tag like that... its a singular tag, it doesn't enclose anything (and the proper way to do it would be <br /> )

Can you jam with the console cowboys in cyberspace?
evanthebouncy!
Profile Blog Joined June 2006
United States12796 Posts
June 01 2008 23:16 GMT
#16
On June 01 2008 21:10 stenole wrote:
Show nested quote +
On June 01 2008 20:33 evanthebouncy! wrote:
I'll explain:
(waa) is a loop, it basically runs another recursive function w/ input of 1, this function is called wee

If we ever worked on a programming project together, I would probably have to kill you. wee and waa are not good names for things unless you are trying to make code unreadable on purpose.

chill :p I'm more of a mathmatics major
Life is run, it is dance, it is fast, passionate and BAM!, you dance and sing and booze while you can for now is the time and time is mine. Smile and laugh when still can for now is the time and soon you die!
Please log in or register to reply.
Live Events Refresh
Next event in 3h 35m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 208
StarCraft: Brood War
TY 3441
Mind 92
ToSsGirL 57
Shinee 27
Noble 14
League of Legends
JimRising 757
Counter-Strike
Stewie2K638
Super Smash Bros
Mew2King143
Heroes of the Storm
Khaldor117
Other Games
summit1g7791
C9.Mang0419
Skadoodle187
Organizations
Other Games
gamesdonequick793
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• practicex 97
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 137
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift3643
• Lourlo1035
• Stunt327
• HappyZerGling96
Upcoming Events
Road to EWC
3h 35m
Road to EWC
4h 35m
Road to EWC
16h 35m
Road to EWC
1d 3h
Road to EWC
1d 10h
BSL Season 20
1d 12h
Sziky vs Razz
Sziky vs StRyKeR
Sziky vs DragOn
Sziky vs Tech
Razz vs StRyKeR
Razz vs DragOn
Razz vs Tech
DragOn vs Tech
Online Event
1d 22h
Clem vs ShoWTimE
herO vs MaxPax
Road to EWC
2 days
BSL Season 20
2 days
Bonyth vs Doodle
Bonyth vs izu
Bonyth vs MadiNho
Bonyth vs TerrOr
MadiNho vs TerrOr
Doodle vs izu
Doodle vs MadiNho
Doodle vs TerrOr
Replay Cast
2 days
[ Show More ]
Replay Cast
3 days
Replay Cast
4 days
The PondCast
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2025-05-28
DreamHack Dallas 2025
Calamity Stars S2

Ongoing

JPL Season 2
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL Season 17: Qualifier 1
2025 GSL S2
Heroes 10 EU
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
ECL Season 49: Europe
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

CSL Season 17: Qualifier 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLAN 2025
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Bellum Gens Elite Stara Zagora 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.