有没有大佬帮忙看看错在哪了,一直显示运行错误
查看原帖
有没有大佬帮忙看看错在哪了,一直显示运行错误
434244
abcd231楼主2021/3/17 17:19
#include<stdio.h>
int main()
{
	int x=0,y=0,i;
	char str[160],ch;
	for(i=0;(ch=getchar())!='\n';i++)
	{
		str[i]=ch;
		if(str[i]=='b')
		x++;
		else if(str[i]=='o'&&str[i-1]!='b'&&(i-1>0))
		x++;
		else if(str[i]=='y'&&str[i-1]!='o'&&(i-1>0))
		x++;
		if(str[i]=='g')
		y++;
		else if(str[i]=='i'&&str[i-1]!='g'&&(i-1>0))
		y++;
		else if(str[i]=='r'&&str[i-1]!='i'&&(i-1>0))
		y++;
		else if(str[i]=='l'&&str[i-1]!='r'&&(i-1>0))
		y++;
	}
	printf("%d\n%d",x,y);
	return 0;
}
2021/3/17 17:19
加载中...