关于find
  • 板块学术版
  • 楼主IQ勇士
  • 当前回复9
  • 已保存回复9
  • 发布时间2021/10/4 15:24
  • 上次更新2023/11/4 04:54:11
查看原帖
关于find
158652
IQ勇士楼主2021/10/4 15:24

RT,在某篇题解里面看见使用find函数为查找成功是会返回18446744073709551611844674407370955161的,但是我使用如下的代码来侦测是否未查询到目标却依然成功,请问其中的机制是什么呢?

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	string s = "1145149191810", h;
	while(1)
	{
		cin >> h;
		long long x = s.find(h);
		if(x == -1)
		{
			cout << "Not found" << endl;
		}
		else
			cout << x << endl;
	}
}
2021/10/4 15:24
加载中...