萌新求助,请问我这样写有什么问题?为什么每次find函数返回值都是-1???
代码:
#include<cstdio>
#include<string>
using namespace std;
int main()
{
string three = "abcdefghijklmnotuv", four = "pqrswxyz";
char a;
int cnt = 0;
while(a = getchar() != EOF)
{
if(three.find(a) != -1)
cnt += (three.find(a) % 3);
else if(four.find(a) != -1)
cnt += four.find(a) % 4;
else
cnt++;
}
printf("%d", cnt);
return 0;
}
有哪位大佬可以帮忙解答一下,谢谢!