• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:57
CEST 23:57
KST 06:57
  • 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
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Chinese SC2 server to reopen; live all-star event in Hangzhou21Weekly Cups (Oct 13-19): Clem Goes for Four3BSL Team A vs Koreans - Sat-Sun 16:00 CET7Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)81
StarCraft 2
General
RotterdaM "Serral is the GOAT, and it's not close" Chinese SC2 server to reopen; live all-star event in Hangzhou The New Patch Killed Mech! Weekly Cups (Oct 13-19): Clem Goes for Four 5.0.15 Patch Balance Hotfix (2025-10-8)
Tourneys
Merivale 8 Open - LAN - Stellar Fest Tenacious Turtle Tussle RSL Season 3 Qualifier Links and Dates $1,200 WardiTV October (Oct 21st-31st) SC2's Safe House 2 - October 18 & 19
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
OGN to release AI-upscaled StarLeague from Feb 24 Is there anyway to get a private coach? BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ SnOw's Awful Building Placements vs barracks
Tourneys
Small VOD Thread 2.0 ASL final tickets help [Megathread] Daily Proleagues [ASL20] Semifinal B
Strategy
Roaring Currents ASL final Relatively freeroll strategies BW - ajfirecracker Strategy & Training TvP Upgrades
Other Games
General Games
Path of Exile Nintendo Switch Thread Stormgate/Frost Giant Megathread Dawn of War IV ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread The Chess Thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Korean Music Discussion Anime Discussion Thread Series you have seen recently... Movie Discussion!
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The Benefits Of Limited Comm…
TrAiDoS
Sabrina was soooo lame on S…
Peanutsc
Our Last Hope in th…
KrillinFromwales
Certified Crazy
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1352 users

help with computing algorithms!

Blogs > GTR-2-Go
Post a Reply
GTR
Profile Blog Joined September 2004
51490 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
51490 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
Zurich15353 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
51490 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 States24721 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 4m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
UpATreeSC 210
ProTech103
PiGStarcraft0
StarCraft: Brood War
Britney 23669
Bisu 3810
Larva 216
Hyun 131
ggaemo 64
Dota 2
syndereN417
canceldota134
Counter-Strike
Stewie2K483
Foxcn134
Heroes of the Storm
Liquid`Hasu519
Trikslyr47
Other Games
FrodaN3634
Grubby2392
fl0m612
shahzam538
mouzStarbuck327
ToD200
KnowMe183
C9.Mang0116
ViBE73
PPMD32
fpsfer 1
Organizations
Counter-Strike
PGL181
Other Games
BasetradeTV25
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• StrangeGG 99
• RyuSc2 32
• davetesta31
• OhrlRock 4
• LaughNgamezSOOP
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• sooper7s
• Migwel
StarCraft: Brood War
• RayReign 31
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• Noizen30
League of Legends
• Doublelift2325
Other Games
• imaqtpie1484
• Shiphtur184
Upcoming Events
The PiG Daily
4m
ByuN vs Solar
Reynor vs herO
MaxPax vs Solar
Clem vs MaxPax
RSL Revival
4h 4m
RSL Revival
12h 4m
WardiTV Invitational
13h 4m
OSC
17h 4m
SKillous vs goblin
Spirit vs GgMaChine
ByuN vs MaxPax
Afreeca Starleague
1d 10h
Snow vs Soma
Sparkling Tuna Cup
1d 12h
WardiTV Invitational
1d 14h
CrankTV Team League
1d 15h
BASILISK vs Streamerzone
Team Liquid vs Shopify Rebellion
Team Vitality vs Team Falcon
RSL Revival
1d 19h
[ Show More ]
Wardi Open
2 days
CrankTV Team League
2 days
Replay Cast
3 days
WardiTV Invitational
3 days
CrankTV Team League
3 days
Replay Cast
4 days
CrankTV Team League
4 days
Replay Cast
5 days
The PondCast
5 days
CrankTV Team League
5 days
Replay Cast
6 days
WardiTV Invitational
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 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.