参考代码:
#include<bits/stdc++.h> using namespace std; char s[20000]; bool fx(char* s1, char* s2) //暴力搜索s1在s2中是否存在 { int n=0,i = 0, j = 0; while (n != strlen(s1) && strlen(s2) - j >=strlen(s1)-n) { if (s1[i] == s[j]) { i++; j++; n++; } else { i = 0; j = j - n + 1; n = 0; } } return n == strlen(s1); } int main() { char c[9]; cin >> s; int n,sum=0; cin >> n; while (n--) { cin >> c; sort(c, c + 8); //从最小开始排序 do { sum+=(int)fx(c, s); } while (next_permutation(c, c + 8)); //next_permutation实现字典排序 } cout << sum; }
0.0分
3 人评分
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:509 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:697 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:576 |
简单的a+b (C语言代码)浏览:585 |
C语言训练-大、小写问题 (C语言代码)浏览:611 |
简单的a+b (C语言代码)浏览:625 |
WU-输出正反三角形 (C++代码)浏览:1011 |
简单的a+b (C语言代码)浏览:805 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:460 |
简单的a+b (C语言代码)浏览:478 |