Search:

Type: Posts; User: Norm

Search: Search took 0.10 seconds.

  1. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    You're welcome.
  2. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    That is an example of a for loop that controls two indexes. It is only an example.
    Did you copy it to a test class, compile and execute it to see how the values of i and j change? If that is too...
  3. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    The for loop has a built in index usage feature. You can then manually write code that executes inside the loop for any other indexes you need.

    Alternately the for loop can handle multiple...
  4. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    Did you understand and work through my suggestions in post#8?
    Using the variable names suggested in post#10 will help.
  5. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    Are you asking how to build the full String from the array's elements?
    Use the concatenation operator: + in a loop to concatenate all the elements to a String.
  6. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    Look at the logic I suggested in post#8. Did you do the paper and pencil exercise?


    How did you create and populate the array? That will determine the index to the last element in the array.
    ...
  7. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    To work out the steps the code must take to solve the problem, take a piece of paper and write on a line a sample list of words. Then put pointers under the first words to be swapped(the first one...
  8. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    That swap should be very easy.


    That would take a loop with some indexes to keep track of what elements to swap.

    What have you tried?
  9. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    Can you explain what words are supposed to be swapped?
    Why do you think there needs to be a loop to do the swapping? A loop would be used if all the words need to be moved around. If there are...
  10. Thread: swapping.

    by Norm
    Replies
    22
    Views
    979

    Re: swapping.

    Put the words in an array where swapping them will be easy.
Results 1 to 10 of 10