Good afternoon. I need to enter an integer and determine whether there are two identical numbers which are located fairly close to each others( standing side by side). For instance, my input is "1224" and the output is "YES". Or my input is "1256" and the output is "NO". I tried to do it like that:
{int a,b,c,d,i;
scanf("%d",&i);
while (i!=0)
{
a=i/1000;
b=(i/100)%10;
c=(i%100)/10;
d=i%10;
}
if (a==b || b==c || c==d)
{printf("YES");}
else
{printf("NO");}
return 0;
}
However, it failed. My classmates said me that "i" does not changes and, as a result, my code does not work. Unfortunately, i did not understand what they meant. So, could you tell me what's wrong in this code?