高精度加法
高精度加法使用数组存储每个数字的每个位数,对于两个输入的超长整数字符串,程序能够在逐位相加时实现进位。最后将结果再次转化为字符串输出。
代码实现12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970#include<iostream> #include<cstring>using namespace std;/* 将两个字符串翻转存储到数组中 */void rev(int fir[], int sec[], string a, string b) { for(int i = 0; i < a.length(); i++) { // 将第一个字符串翻转存储到 fir 数组中 fir[i] = a[a.length() - i - 1] - '0'; } ...
KMP算法
KMP算法KMP算法是一种用于在字符串匹配过程中提高匹配效率的算法,被广泛应用于字符串匹配和文本搜索领域。通过预处理模式串的next数组,以减少匹配的次数,从而优化算法效率。
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970#include<iostream>#include<cstring>using namespace std;//KMP算法主体int index(string S,string T,int next[]){ int i,j; for(i=1,j=1;i<S.length()&&j<T.length();) { if(S[i]==T[j]||j==0)//字符匹配或者T串已经退到第一个位置 { i++; ...
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generate
More info: Generating
Deploy to remote sites1$ hexo deploy
More info: Deployment