跳到正文

个人记录

常用代码模板

wwwidk1234约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

字符串分割

C++
inline vector<string> split(string s,char c)
{
	vector<string> res;
	string t;
	for(char _:s)
	{
		if(_==c)
		{
			res.push_back(t);
			t.clear();
		}
		else t.push_back(_);
	}
	res.push_back(t);
	return res;
}

string 转 int

C++
int to_num(string s)
{
	stringstream ss;int a;
	ss<<s;ss>>a;
	return a;
}

GCD(注意特判 0)

C++
inline int gcd(int a,int b)
{
	while(b^=a^=b^=a%=b);
	return a;
}
原文