diff --git a/GESP/2023060401.cpp b/GESP/2023060401.cpp new file mode 100644 index 0000000..a053f2b --- /dev/null +++ b/GESP/2023060401.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; +const int N = 1010; +int b[N]; // 1、定义桶 +/* +3 3 +0 2 1 +*/ +int main() { + // 2、处理输入输出 + int n, m; + cin >> n >> m; // n:有n个同学,m:报了m次数 + + while (m--) { + int x; + cin >> x; + b[x] = 1; + } + bool flag = false; + for (int i = 0; i < n; i++) + if (!b[i]) { + flag = true; + cout << i << " "; + } + + if (!flag) { + cout << n << endl; + } + return 0; +} \ No newline at end of file diff --git a/GESP/2023060402_01.cpp b/GESP/2023060402_01.cpp new file mode 100644 index 0000000..e4e308f --- /dev/null +++ b/GESP/2023060402_01.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; +void check(string t) { + // 1、必须有大写,小写,数字三种中的两种 + int dx = 0, xx = 0, sz = 0, ts = 0; + // 2、四个特殊字符必须有一个 + // !@#$ + + // 3、不能出现其它字符 + for (int i = 0; i < t.size(); i++) { + if (t[i] >= 'A' && t[i] <= 'Z') + dx = 1; + if (t[i] >= 'a' && t[i] <= 'z') + xx = 1; + if (t[i] == '!' || t[i] == '@' || t[i] == '#' || t[i] == '$') + ts = 1; + if (t[i] >= '0' && t[i] <= '9') + sz = 1; + + if (!(t[i] >= 'A' && t[i] <= 'Z') && !(t[i] >= 'a' && t[i] <= 'z') && !(t[i] >= '0' && t[i] <= '9') && + t[i] != '!' && t[i] != '@' && t[i] != '#' && t[i] != '$') { + return; + } + } + if (dx + xx + sz < 2) return; + if (ts == 0) return; + cout << t << endl; +} +int main() { + string s; + cin >> s; + s += ','; + + string t = ""; + for (int i = 0; i < s.size(); i++) { + if (s[i] == ',') { + check(t); + t = ""; + + } else + t += s[i]; + } + + return 0; +} \ No newline at end of file diff --git a/GESP/2023060402_2.cpp b/GESP/2023060402_2.cpp new file mode 100644 index 0000000..dec5108 --- /dev/null +++ b/GESP/2023060402_2.cpp @@ -0,0 +1,34 @@ +#include +using namespace std; + +set _set = {'!', '@', '#', '$'}; + +void check(string t) { + int dx = 0, xx = 0, sz = 0, ts = 0; + for (int i = 0; i < t.size(); i++) { + if (isupper(t[i])) dx = 1; + if (islower(t[i])) xx = 1; + if (_set.count(t[i])) ts = 1; + if (isdigit(t[i])) sz = 1; + if (!isupper(t[i]) && !islower(t[i]) && !isdigit(t[i]) && !_set.count(t[i])) return; + } + if (dx + xx + sz < 2) return; + if (ts == 0) return; + cout << t << endl; +} +int main() { + string s; + cin >> s; + s += ','; + + string t = ""; + for (int i = 0; i < s.size(); i++) { + if (s[i] == ',') { + check(t); + t = ""; + } else + t += s[i]; + } + + return 0; +} \ No newline at end of file diff --git a/GESP/GESP C++四级认证试卷2023年6月.pdf b/GESP/GESP C++四级认证试卷2023年6月.pdf index 1f27828..8be8e23 100644 Binary files a/GESP/GESP C++四级认证试卷2023年6月.pdf and b/GESP/GESP C++四级认证试卷2023年6月.pdf differ diff --git a/GESP/SheXingJuZhen.cpp b/GESP/SheXingJuZhen.cpp index 4564fb7..142cc76 100644 --- a/GESP/SheXingJuZhen.cpp +++ b/GESP/SheXingJuZhen.cpp @@ -9,8 +9,8 @@ int n, m; int main() { cin >> n >> m; - for (int k = 1; k <= n * m; k++) { // 没有填充完毕 - a[x][y] = k; // 在当前位置填充数字, 值在长大 + for (int i = 1; i <= n * m; i++) { // 没有填充完毕 + a[x][y] = i; // 在当前位置填充数字, 值在长大 // p是说方向数组中的游标,它是需要变化的,什么情况下变化呢? // 1、出界了就变化 2、遇到了障碍就变化 int tx = x + dx[p], ty = y + dy[p]; // 蛇准备去的位置 diff --git a/GESP/TangDou.cpp b/GESP/TangDou.cpp new file mode 100644 index 0000000..5315434 --- /dev/null +++ b/GESP/TangDou.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; +string zshiliu(int u) { + char q, p; + string s = ""; + if (u / 16 >= 10) + p = 'A' + u / 16 - 10; + else + p = '0' + u / 16; + s += p; + if (u % 16 >= 10) + q = 'A' + u % 16 - 10; + else + q = '0' + u % 16; + s += q; + return s; +} +int zshi(string s) { + int a = 0; + if (s[0] >= 'A' && s[0] <= 'F') + a = (s[0] - 'A' + 10) * 16; + else if (s[0] >= '0' && s[0] <= '9') + a = (s[0] - '0') * 16; + + int b = 0; + if (s[1] >= 'A' && s[1] <= 'F') + b = (s[1] - 'A' + 10); + else if (s[1] >= '0' && s[1] <= '9') + b = (s[1] - '0'); + + return a + b; +} + +int main() { + cout << zshiliu(10) << endl; + cout << zshi("FF") << endl; + cout << zshi("AA") << endl; + return 0; +} \ No newline at end of file diff --git a/GESP/dad.cpp b/GESP/dad.cpp new file mode 100644 index 0000000..eb84fda --- /dev/null +++ b/GESP/dad.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; +const int N = 40; +int n; //一个n*n的幻方 +int g[N][N]; //一个二维数组用来存储幻方 +int x, y; //用来记录上一个位置 + +int main() { + cin >> n; + //1≤N≤39 且 N 为奇数。 + + //(1)首先,将1写在第一行的中间 + g[1][n / 2 + 1] = 1; // n/2+1,是因为n是奇数噢,偶数不用+1 + + //记录上一个放置的位置【这个很重要,一定要记录上一次的位置!!!】 + x = 1; + y = n / 2 + 1; + + //尝试将2-n^2的数字放入 [核心思想:上一个位置] + for (int i = 2; i <= n * n; i++) { + if (x == 1 && y != n) g[n][y + 1] = i, x = n, y++; + else if (y == n && x != 1) g[x - 1][1] = i, x--, y = 1; + else if (x == 1 && y == n)g[2][n] = i, x = 2; + else if (x != 1 && y != n) { + if (g[x - 1][y + 1] == 0) g[x - 1][y + 1] = i, x--, y++; + else g[x + 1][y] = i, x++; + } + } + //输出 + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) + cout << g[i][j] << " "; + cout << endl; + } + return 0; +} diff --git a/GESP/穷举法.md b/GESP/穷举法.md index 7fe4a9d..dda1826 100644 --- a/GESP/穷举法.md +++ b/GESP/穷举法.md @@ -23,13 +23,13 @@ Cock=0; while (Cock<=19) /*公鸡最多不可能大于19*/ { Hen=0; - whlie (Hen<=33) /*母鸡最多不可能大于33*/ + while (Hen<=33) /*母鸡最多不可能大于33*/ { Chick=100-Cock-Hen; - if (Cock*15+Hen*9+Chick==300)/*为了方便,将数量放大三倍比较*/ - printf("\n公鸡=%d\n母鸡=%d\n雏鸡=%d",Cock,Hen,Chick); - Hen=Hen+1; -} + if (Cock*15+Hen*9+Chick==300)/*为了方便,将数量放大三倍比较*/ + printf("\n公鸡=%d\n母鸡=%d\n雏鸡=%d",Cock,Hen,Chick); + Hen=Hen+1; + } Cock=Cock+1; } ``` \ No newline at end of file diff --git a/VsCode配置/VsCode配置20230216.rar b/VsCode配置/VsCode配置20230216.rar deleted file mode 100644 index 3d7e24a..0000000 Binary files a/VsCode配置/VsCode配置20230216.rar and /dev/null differ