Little Man Programming: Get Help Now

  • Thread starter Thread starter Matt3453
  • Start date Start date
  • Tags Tags
    Programming
AI Thread Summary
A user seeks assistance in creating a Little Man program to sort three user inputs from largest to smallest, expressing confusion about where to start. Forum members inquire about the programming language, operating system, and resources being used, emphasizing that they won't complete the work but can provide guidance. Suggestions include utilizing a bubble sort algorithm and comparing values to determine their order. The discussion includes code snippets and logic for comparing and sorting the inputs. The conversation highlights the importance of understanding sorting algorithms and encourages the user to refer to their textbook for further clarification.
Matt3453
Messages
5
Reaction score
0
Hello everyone,

New to the forums and I really need some help. I'm trying to create a little man program that would accept any three user inputs and return them in order from largest to smallest. I really have no clue where to start since I'm completely new to programming. Please help..
 
Physics news on Phys.org
Matt3453 said:
Hello everyone,

New to the forums and I really need some help. I'm trying to create a little man program that would accept any three user inputs and return them in order from largest to smallest. I really have no clue where to start since I'm completely new to programming. Please help..

Welcome to the PF. What language are you programming in? What OS and GUI and development system are you using? What is your textbook or online reference to the language?

We don't do your schoolwork for you here at the PF, but we can offer you some tutorial hints and questions to get you going.
 
Its Little Man and the textbook is by Englander, Computer Hardware and Systems Software. From what I understand, this is how to find the largest, but how does one go about modifying it to find them in order
00 : 901
01 : 397
02 : 901
03 : 398
04 : 901
05 : 399
06 : 297
07 : 810
08 : 597
09 : 611
10 : 599
11 : 298
12 : 815
13 : 598
14 : 616
15 : 599
16 : 902
17 : 000
97 : 000 DATA
98 : 000 DATA
99 : 000 DATA
 
Compare first with the second - if first is larger, exchange them. Compare second with third - if second is larger, exchange them. Not all are sorted yet, but at least the largest is in its final position...
 
Borek said:
Compare first with the second - if first is larger, exchange them. Compare second with third - if second is larger, exchange them. Not all are sorted yet, but at least the largest is in its final position...
Then compare the first with the second. If the second is smaller, exchange with the first. That should leave you with the smallest in the first position and the largest in the third position. The one whose value is between the smallest and largest is in the middle.
 
Does this seem right?

00 INP 901
01 STO 97 397
02 INP 901
03 STO 98 398
04 INP 901
05 STO 99 399
06 SUB 97 297
07 BRP 810
08 LDA 97 597
09 BR 611
10 LDA 99 599
11 SUB 98 298
12 BRP 815
13 LDA 98 598
14 BR 616
15 LDA 99 599
16 OUT 902 - Output as largest
17 LDA 98 398
18 SUB 97 297
19 BRP 826
20 LDA 97 597
21 BR 622
22 LDA 97 597
23 OUT 902 - Output as second largest
24 LDA 98 598
25 OUT 902 - Output as smallest
26 LDA 98 598
27 OUT 902 - Output as second largest
28 LDA 597
29 OUT 902 - Output as smallest30 LDA 98 598
31 SUB 99 299
32 BRP 839
33 LDA 99 599
34 BR 635
35 LDA 99 599
36 OUT 902 - Output as second largest
37 LDA 98 598
38 OUT 902 - Output as smallest
39 LDA 98 598
40 OUT 902 - Output as second largest
41 LDA 99 599
42 OUT 902 - Output as smallest
43 HLT 000

99 DAT 000
98 DAT 000
97 DAT 000

99 DAT 000
97 DAT 000
98 DAT 000
I already found the largest number, so all I have to do is sort the last two numbers.
 
Ah, there is nothing like to solve the question to the end, not leaving place for the OP to think on her/his own :-p
 
So, I don't understand? It's flawed somewhere? What's OP mean?
 
00 inp 901
01 sto 90 390
02 inp 901
03 sto 91 392
04 inp 901
05 sto 93 393
06 lda 90 590
07 sub 91 291
08 brp 812
09 lda 91 391
10 out 902
11 br 614
12 lda 90 390
13 out 902
14 lda 91 591
15 sub 92 292
16 brp 820
17 lda 92 392
18 out 902
19 br 622
20 lda 91 391
21 out 902
22 lda 90 590
23 sub 91 291
24 brp 829
25 lda 90 591
28 out 902
29 lda 91 590
30 out 902
31 hlt 000
 
  • #10
OP means Original Poster, that's you.
 
  • #11
Look for information in your book on "Bubble Sort". Find the algorithm described and compare this to the flow chart which your book should show.
 

Similar threads

Replies
7
Views
3K
Replies
5
Views
5K
Replies
1
Views
2K
Replies
3
Views
1K
Replies
9
Views
4K
Replies
12
Views
2K
Back
Top