So my program is supposed to turn the numbers put by the users in a clockwise fashion, but i receive lots of 2s and 1s as well as an impossible number. Any help would be appreciated as I am at my wits' end.
#include <iostream>
#include <iomanip>
usingnamespace std;
void turn(int [], int &);
void main()
{
int numbers [10];
int turns;
char k;
bool done;
done=false;
cout<<"Enter 10 numbers: ";
for (int i=0;i<10;i++)
{
cin>>numbers [i];
}
cout<<"Enter the number of turns that will be made (value must be postive)";
cout<<"\n";
cout<<"x= ";
while (!done)
{
cin>>turns;
if (turns<0)
{
done=false;
}
else
{
done=true;
}
}
cout<<"\n";
turn (numbers, turns);
cout<<"\n";
cout<<"Enter any character to continue...";
cout<<"\n";
cin>>k;
}
void turn(int numbers[], int &turns)
{
int backup[10];
char k;
if (turns==0)
{
cout<<"Number arrangement will remain the same.";
cout<<"\n";
cout<<"Enter any character to exit...";
cout<<"\n";
cin>>k;
exit (1);
}
for (int k=0;k<turns;k++)
{
backup[k]=numbers[10-k];
for (int j=0;j<10;j++)
{
numbers [j+1]=numbers [j];
cout<<numbers [j+1];
}
}
for (int r=0;r<turns;r++)
{
numbers[r]=backup[r];
cout<<numbers[r];
}
}