check 2d array error

Here is requirement, the array[4][4] can only be placed with number from 1-9 and all them need to form a pair.

ex: 1 1 2 2
3 3 4 4
5 5 6 6
7 7 8 8
but the number can only be used to make a pair which mean, if user input 1,1,1 or 1,1,1,1 will get error. If the user entered 2 number which not a pair also error.

error ex: 1 1 2 2
3 3 4 4
5 5 6 6
7 7 8 9

Here is the code,i have a rough mindset of how to make it only but using x4 for loop seems to get me error for some reason i haven't input while loop since i couldn't even settle the current problem so if there is any help with details codes and explanation will be very appreciate.
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
#include <stdio.h>
void main()
{
	int num[4][4];
	int x,y,row,col,N,n=0;

	printf("come\n");

	for(row=0;row<4;row++)
	{
		for(col=0;col<4;col++)
		{
			scanf("%d",&num[row][col]);
		}
	}

	for(row=0;row<4;row++)
	{
		for(col=0;col<4;col++)
		{
			N=num[row][col];
			
			for(x=0;x<4;x++)
			{
				for(y=0;y<4;y++)
				{
				}
				
					if(row==x && col==y)
					{
						break;
					}

					if(N == num[x][y])
					{
						n++;
				}
			}
		}
	}	
	if(n>2)
	{
		printf("Sorry but only one number per pair!");
	}




	printf("\n\n\n");

	for(row=0;row<1;row++)
	{
		for(col=0;col<4;col++)
		{
			printf("%d",num[row][col]);
		}
		printf("\n");
	}

}

Topic archived. No new replies allowed.