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/TangDou.cpp b/GESP/TangDou.cpp index 16d5036..5315434 100644 --- a/GESP/TangDou.cpp +++ b/GESP/TangDou.cpp @@ -1,22 +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 main() { - for (int i = 1;; i++) { - int flag = 0; - int x = i; - for (int j = 1; j <= 5; j++) { - if ((x - 1 <= 0) || (x - 1) % 5 > 0) { - flag = 1; - break; - } - x = (x - 1) / 5 * (5 - 1); - } - if (flag == 0) { - cout << i << endl; - exit(0); - } - } + 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