#include <stdio.h>
int main() {
int num;
scanf("%d",&num);
int prev=num%10;
num=num/10;
int find=0;
while(num>0){
int now=num%10;
if(now==prev){
find=1;
break;
}
prev=now;
num=num/10;
}
if(find==1)printf("YES");
else printf("NO");
return
}
This program reads an integer, then checks if any two adjacent digits in the number are equal. It extracts digits from right to left, comparing each digit to the previous one. If a match is found, it prints "YES"; otherwise, it prints "NO".
- The line `return` is incomplete. In C, every function that returns a value must have a complete return statement with a value, like `return 0;`.
- The variable `find` is set to 1 when adjacent equal digits are found, but the logic only compares the current digit to the immediately previous digit. Consider whether the problem requires checking any two equal digits anywhere in the number, not just adjacent ones.