Cyclic Permutation in C

by TheSourceCode
Tags: cyclic, permutation
TheSourceCode is offline
Feb22-12, 11:39 PM
P: 14
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.
Phys.Org News Partner Science news on
Cougars' diverse diet helped them survive the Pleistocene mass extinction
Cyber risks can cause disruption on scale of 2008 crisis, study says
Mantis shrimp stronger than airplanes
Joffan is offline
Feb23-12, 12:09 AM
P: 329
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.
TheSourceCode is offline
Feb23-12, 11:13 AM
P: 14
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.

Register to reply

Related Discussions
prove product of infinite cyclic groups not an infinite cyclic group Calculus & Beyond Homework 3
Lagrangian formalism: cyclic coordinates. Why "cyclic"? Where's the term come from? Classical Physics 0
Conjugation of a permutation by a permutation in a permutation group Calculus & Beyond Homework 3
Permutation Precalculus Mathematics Homework 1
Differentiate between cyclic and non cyclic phosphorilation in photosynthesis? Biology 0