How can I rotate these 4 numbers each time I run the program?

I'm a freshman at my HS taking a C++ class, sorry for bad code or mistakes.
How do I make these numbers: 1,3,7,2 rotate numerical orders everytime the program runs? Thank you very much

For ex: 1372 will turn to 7132 then 3127 etc... each time the program runs








#include <iostream>
using namespace std;
void shiftNums(int a, int b, int c, int d);
int main()
{
int rotate = 0;
int first = 1;
int second= 3;
int third = 7;
int fourth = 2;

shiftNums(first, second, third, fourth);




system("Pause");
return 0;
}

void shiftNums(int a, int b, int c, int d) {

cout << '(' << a << b <<c <<d <<')';

}
Last edited on
You would need some kind of persistent storage - for instance a file - that can retain information across multiple runs of the program.
rotate numerical orders

Rotate once? Something like dummy = first, first = second, second = third, third = fourth, fourth = dummy. Or std::swap(first, second); std::swap(second, third); std::swap( third, fourth); up to you.
Repeate da capo.
MikeStgt,

Thank you very much for your advice, I solved it now because of you. Appreciate it!
In what sense is 1372 to 7132 to 3127 a "rotation"?
In what sense is 1372 to 7132 to 3127 a "rotation"?
How did you get this results? Pls show your complete code.
I did the thing you mentioned above. I meant to SWAP the numbers around. I did this for example.

int temp;
int x=2;
int h=5;
int j=3;
int o=7;

temp=x;
x=h;
h=j;
j=o;
o=temp;
Thank you thekiid718, but I asked dutch for details about his append http://www.cplusplus.com/forum/general/252858/#msg1112618
closed account (z05DSL3A)
MikeStgt,

In the original post
thekiid718 wrote:
For ex: 1372 will turn to 7132 then 3127 etc...

so where do you think dutch got his numbers from?
Last edited on
@Grey Wolf

Ha -- what a finding! :) Tnx
In the OP I read
rotate numerical orders
and thus not the examples.
Topic archived. No new replies allowed.