Clockwise turn gives weird numbers

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <iomanip>
using namespace 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];
	}
}
Topic archived. No new replies allowed.