最简单的游戏有关问题

最简单的游戏问题?
大家都玩过猜数字吧!!
                 

            要求随机生成4   个数,要不能相同,且不能大于10只能是(0,1,2,3,4,5,6,7,8,9,0);我们可以把它放在一个一维数组中a[4]中;
            再输入4个数,也是4个不相同的数;可以用Scanf()函数,我们把它放在b[4]中;
            如果对应的位置有N个相同则输出N   A;
            如果有M数字相同则输出M   B;
   
        例如随机生成了0123;而你输入的是3210则输出的结果是0A4B;
                                            若你输入的是0145则输出的结果是2A2B;

        简单吧;


------解决方案--------------------
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define SIZE 4
main()
{
int enter=1,stop,a[SIZE],b[SIZE],guessnum,i,j,counter,countera,counterb,counter0,extra;
char ch;
srand(time(NULL));

while(enter==1){
stop=2;
while(stop==2){
extra=1;
for(i=0;i <=SIZE-1;i++){
a[i]=rand()%10;
}
for(i=0;i <=SIZE-1;i++){
for(j=i+1;j <=SIZE-1;j++){
if(a[i]==a[j]) extra=2;
}
}
if(a[0]!=0&&extra==1) {stop=1;printf( "%d%d%d%d ",a[0],a[1],a[2],a[3]);}
}

counter=1;
while(counter <=6){
printf( "Please guess the number:\n ");
scanf( "%d ",&guessnum);
for(i=0;i <=SIZE-1;i++){
b[i]=guessnum/(int)pow(10,SIZE-1-i)%10;
}
countera=0;
for(i=0;i <=SIZE-1;i++){
if(a[i]==b[i])
countera++;
}
counter0=0;
for(i=0;i <=SIZE-1;i++){
for(j=0;j <=SIZE-1;j++){
if(a[i]==b[j]) counter0++;
}
}
counterb=(counter0-countera);
if(countera==4){
printf( "Wonderful!You guessed the number.Then,please input your choice, '1 ' represents going on, '2 ' represents breaking\n ");
counter=7;
scanf( "%d ",&enter);
}
else {
printf( "%dA%dB\n ",countera,counterb);
counter++;
}
}
}

while((ch=getchar())!= 's '&&ch!= 'S ');
return 0;
}