Menu

Would any of you help me with my homework ??

2007-08-15
2012-09-26
  • Nobody/Anonymous

    I have to do a program that put ten any numbers in order. I mean, the user inputs ten number, no matter how, and the program has to put them in order. The teacher said we can´t use arrays for this.
    Please help me with it.

    Regards,
    Alexandrus

     
    • Wayne Keen

      Wayne Keen - 2007-08-15

      What do you have so far? Code? Thoughts about code? Ideas?

      (Did you read the note in the thread titled "Please Read Before Posting a Question" on how
      to go about getting help with homework??? If not, please do so.)

      Wayne

       
    • Wayne Keen

      Wayne Keen - 2007-08-15

      Here is the section from the "Please Read" thread on getting help with homework:


      About Homework


      Despite evidence to the contrary, we do not mind helping with homework
      here. If you follow the following guidelines, you will probably be
      helped in an effective and friendly way:

      (1) Note that we help with homework, we do not write your programs
      for you. We will give you hints, we will post sample code applicable
      to your problem, we will provide useful links. The aim is to enable
      you to do your own homework. Do not expect to post a statement of
      the problem here, and have someone provide you with code that you
      can turn in. (There are also those of us who will post code that
      is close to what you need, but have some errors you will need to
      think about and fix - again, to help you learn, and keep you
      from cheating - if you have been particularly lazy or dishonest,
      we may well post sabotaged code that will make it obvious to
      your teacher that you cheated)

      (2) Don't try to hide or lie about something being homework. That REALLY
      puts off people who can really help you. And it is usually far
      more obvious than you think.

      (3) Don't just post your homework problem, and no code. Post what
      you have written thus far, or your ideas on what you need to write.
      Show that you are working on the problem. If you don't, then it
      simply looks like you are hoping that someone will write the
      program for you.

      (4) In a followup to (3) above, do not post something like "I have
      no idea where to start!". You are either lying to get someone else
      to do your work for you, or you are really being honest. The
      latter, if true, is telling, in a bad way. You see, homework is
      given based on the level you are supposed to be at in the class.
      When you have no idea how to start, this indicates that you are
      very far behind in the class. This is something you need to
      deal with with your teacher. Catching you up from that far behind
      is also a little beyond the scope of what you should feel comfortable
      asking complete strangers to do for you as well.

       
    • Wayne Keen

      Wayne Keen - 2007-08-15

      I do find the fact that your instructor would ask you to not use arrays somewhat
      strange.

      I can see an instructor asking you not to use array operations, i.e. use libraries
      that will do the sorting on an array for you, but to not use arrays at all seems
      to encourage some massive ugliness.

      Wayne

       
      • Osito

        Osito - 2007-08-15

        Maybe he wants them to use malloc and offsets to better understand what arrays really are? I'm reaching here...

         
        • Wayne Keen

          Wayne Keen - 2007-08-15

          An interesting idea - so its not so much to not use arrays as array
          notation....

          Wayne

           
    • Nobody/Anonymous

      What about using a file? (or a vector?)

      Or maybe, before you get into arrays or vectors or files, and since there are just 10, the teacher wants to illustrate (down the road) the benefits of looping through an array or a vector or dumping new numbers into a file ... ?

      ... by having you NOW just input ten numbers using brute force, like this (for 3 numbers):

      / brute force 3 number sort /

      / tenNum.c /

      include <stdio.h>

      include <stdlib.h>

      void swap( int num1, int num2)
      {
      int temp;
      temp = num1;
      num1 = num2;
      num2 = temp;
      }

      int main()
      {
      int a,b,c;

      printf(&quot;Input 3 integers separated by spaces and press \'Enter\' after&quot; 
             &quot; the last entry:\n&quot; );
      scanf( &quot;%d %d %d&quot;, &amp;a, &amp;b, &amp;c);
      
      printf(&quot;Unsorted: %d, %d, %d\n&quot;, a, b, c );
      
      if( b&lt;a ) swap( &amp;a, &amp;b );
      if( c&lt;b ) swap( &amp;b, &amp;c );
      
      if( b&lt;a) swap( &amp;a, &amp;b );
      
      printf(&quot;Sorted: %d, %d, %d\n&quot;, a, b, c );
      
      system(&quot;PAUSE&quot;);
      return 0;
      

      }

       
    • Nobody/Anonymous

      Guys,
      I´m really feel sorry about this.
      I should read the rules first.
      I am going to talk about this with my teacher, I can´t understand why we can´t use arrays.
      I hope there is a reason for it.

      Regards,

      Alexandrus

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.