1. Limited time only! Sign up for a free 30min personal 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!

Homework Help: Cyclic Permutation in C

  1. Feb 22, 2012 #1
    Use nested for loops to produce the following pattern of cyclic permutations of the English
    HINT: you may find the modulo (remainder) operator % useful.

    I have an idea of how to do this but it would not use the modulo operator. I thought of saving the first letter of an array into a variable, shifting everything else down one and putting it at the end. This also would only implement a single for loop. Any clues would be greatly appreciated.
  2. jcsd
  3. Feb 23, 2012 #2
    Yes, there are probably a million ways to do this, but I suggest that you have one loop generating the first character of each string and an inner loop (since that what was asked for) generating the successive letters of each string - using modulo operator to make the wrap from z to a.
  4. Feb 23, 2012 #3
    Thanks a lot. Took me a bit to get the wrap around to work properly but I got it. I don't think modulo was very intuitive to me before but now I get it.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook