输入一行字符串(长度小于80),以换行符结束。判断其中是否存在两个相邻字符相同的情形。若有,输出YES。反之输出NO。
2019-11-27 16:10
程序代码:#include <stdio.h>
#include <stdbool.h>
int main( void )
{
char s[81];
scanf( "%[^\n]", s );
bool same = false;
for( const char* p=s; *p && !same; ++p )
same = *p==p[1];
puts( same?"YES":"NO" );
}
2019-11-27 16:31
程序代码:#include <stdio.h>
int main()
{
char ch,ch1=0;
while((ch=getchar())!='\n')
{
if(ch1==ch)
{
printf("YES");
return 0;
}
ch1=ch;
}
printf("NO");
return 0;
}

2019-11-27 18:21