1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Little Man Programming

  1. Oct 17, 2009 #1
    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..
     
  2. jcsd
  3. Oct 17, 2009 #2

    berkeman

    User Avatar

    Staff: Mentor

    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.
     
  4. Oct 17, 2009 #3
    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
     
  5. Oct 17, 2009 #4

    Borek

    User Avatar

    Staff: Mentor

    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...
     
  6. Oct 17, 2009 #5

    Mark44

    Staff: Mentor

    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.
     
  7. Oct 17, 2009 #6
    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 smallest


    30 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.
     
  8. Oct 17, 2009 #7

    Borek

    User Avatar

    Staff: Mentor

    Ah, there is nothing like to solve the question to the end, not leaving place for the OP to think on her/his own :tongue2:
     
  9. Oct 17, 2009 #8
    So, I don't understand? It's flawed somewhere? What's OP mean?
     
  10. Oct 17, 2009 #9
    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
     
  11. Oct 17, 2009 #10

    Borek

    User Avatar

    Staff: Mentor

    OP means Original Poster, that's you.
     
  12. Oct 17, 2009 #11

    symbolipoint

    User Avatar
    Homework Helper
    Education Advisor
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Little Man Programming
  1. Little help (Replies: 2)

Loading...