I have a program that takes an array of numbers A, and shuffles them and saves that value into array B.
I need to find how many steps it would take to return the shuffled numbers to their original conditions.
but I am unsure of how to compare array A to array B
I tried writing a program that returns yes or no depending if the arrays have the same elements but it does not work.
constint i = 5;
you know u just need to put those const int within the square braces ONLY for the declaration of arrays... aftr that in the above code i posted(from ur program!) u can just put int i=5, just in case u needed to change the value of i in the program... as it represents index, it can change in the program!
int same=0,diff=0;
for(int i=0;i<5;i++)
{
if(C[i]==A[i])
++same;
else
++diff;
}
cout<<"Number os same elements : "<<same;
cout<<endl<<"Number of different elements : "<<diff;
well i didnt understand ur qn well mayb... if u want to shuffle the array just use a loop for shuffling...
I did this. This works but prints out 3 yays or nays. how can I modify this so that it prints out "nay" if even one element does not match? and "yay" only if all of them match?
1 2 3 4 5 6 7 8 9 10 11
int A[3] = {1,2,3};
int B[3] = {2,3,4};
int C[3] = {1,2,3};
for(int i = 0; i < 3; i++)
{
if (C[i] == A[i])
cout << "yay" << endl;
else
cout << "nay" << endl;
}