I have a function repsEqual
that takes an array and integer and returns 1 if the array contains only digits of the number in the same order that appear in the same number. Otherwise it returns 0.
int repsEqual(int a[], int len, int n)
If a
is {3,2,0,5,3}
and n
is 32053
return 1
because the array contains only the digits of the number in same order as they are in the number.
If a
is {0,3,2,0,5,3}
and n
is 32053
return 1
; we can ignore leading zeros.
I tried like this
int repsEqual(int a[], int len, int n)
{
int len = sizeof(a)/sizeof(a[0]);
//storing elements in array
for(int i=0;i<len;i++)
{
scanf("%d", &a[i]); //eg storing:3 2 0 5 3
}
//asking user integer number and storing in next array
scanf("%d",&a2[num]);//eg 32053
}
Now I need to check if a2
elements are in same order as a1
, but do not know how to get started.