• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 11:51
CET 17:51
KST 01:51
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3
StarCraft 2
General
Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament StarCraft2.fi 15th Anniversary Cup RSL Offline Finals Info - Dec 13 and 14! Tenacious Turtle Tussle StarCraft Evolution League (SC Evo Biweekly)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night
Brood War
General
Let's talk about Metropolis BW General Discussion [ASL20] Ask the mapmakers — Drop your questions BGH Auto Balance -> http://bghmmr.eu/ Foreign Brood War
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET
Strategy
Fighting Spirit mining rates Current Meta Game Theory for Starcraft How to stay on top of macro?
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread EVE Corporation Path of Exile ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream? The Automated Ban List
Blogs
I decided to write a webnov…
DjKniteX
Physical Exertion During Gam…
TrAiDoS
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1680 users

help with computing algorithms!

Blogs > GTR-2-Go
Post a Reply
GTR
Profile Blog Joined September 2004
51506 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
Austin10833 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
51506 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
Norway869 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
Zurich15357 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
51506 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
Norway869 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 States24745 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 States3702 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 10m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech137
BRAT_OK 100
MindelVK 19
StarCraft: Brood War
Britney 29849
Mini 466
Soma 426
Light 423
actioN 360
Snow 318
Hyuk 262
Hyun 116
Dewaltoss 81
ggaemo 52
[ Show more ]
910 33
Oya187 28
zelot 23
Rock 22
soO 14
HiyA 13
JulyZerg 11
SilentControl 10
Dota 2
Gorgc7118
qojqva3278
singsing3218
Dendi843
syndereN359
Counter-Strike
allub198
Other Games
crisheroes382
Hui .368
RotterdaM252
DeMusliM148
ArmadaUGS135
QueenE101
Organizations
Other Games
BasetradeTV99
StarCraft: Brood War
lovetv 4
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• HeavenSC 82
• IndyKCrew
• AfreecaTV YouTube
• sooper7s
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• FirePhoenix7
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2123
• WagamamaTV429
• Noizen45
League of Legends
• TFBlade1299
Other Games
• Shiphtur102
Upcoming Events
StarCraft2.fi
10m
Tenacious Turtle Tussle
7h 10m
The PondCast
17h 10m
WardiTV 2025
19h 10m
StarCraft2.fi
1d
WardiTV 2025
1d 19h
RSL Revival
2 days
StarCraft2.fi
2 days
IPSL
3 days
Sziky vs JDConan
RSL Revival
3 days
Classic vs TBD
herO vs Zoun
[ Show More ]
WardiTV 2025
3 days
IPSL
4 days
Tarson vs DragOn
Wardi Open
4 days
Monday Night Weeklies
5 days
Replay Cast
5 days
Sparkling Tuna Cup
5 days
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Revival: Season 3
Kuram Kup

Ongoing

IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
WardiTV 2025
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
RSL Offline Finals
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 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.