社区讨论

有没有大佬帮忙看看错在哪了,一直显示运行错误

P1321单词覆盖还原参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@locj48ne
此快照首次捕获于
2023/10/30 14:38
2 年前
此快照最后确认于
2023/11/05 01:57
2 年前
查看原帖
C
#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;
}

回复

2 条回复,欢迎继续交流。

正在加载回复...