本人本人想了一个,不对。具体情况看图,讨教为什么不对,谢谢:)
解决方案
25
=是赋值运算符
==才是比较运算符
==才是比较运算符
25
int count (const char *str) { int ret = 0 ; int state = 0 ; for (int i = 0 ; str[i] != "#" ; i++) { if (state == 0 && str[i] == "e") { state = 1 ; } else if (state == 1 && str[i] == "i") { ret++ ; state = 0 ; } else { state = 0 ; } } return ret ; } int main () { printf ("%d\n" ,count ("eiieiieiss#")) ; return 0 ; }