From 895035f176ce82e1a45c20cf86a56519218a919c Mon Sep 17 00:00:00 2001 From: flykhan Date: Mon, 10 Jul 2023 17:46:22 +0800 Subject: [PATCH] temp --- day6/a.out | Bin 0 -> 15664 bytes day6/d12.c | 19 +++++++++++++++++++ day6/d13.c | 18 ++++++++++++++++++ day6/d14.c | 23 +++++++++++++++++++++++ day6/d15.c | 20 ++++++++++++++++++++ day6/d17.c | 25 +++++++++++++++++++++++++ day6/d18.c | 2 ++ day6/d19.c | 6 ++++++ day6/d6.c | 33 +++++++++++++++++++++++++++++++++ 9 files changed, 146 insertions(+) create mode 100755 day6/a.out create mode 100644 day6/d12.c create mode 100644 day6/d13.c create mode 100644 day6/d14.c create mode 100644 day6/d15.c create mode 100644 day6/d17.c create mode 100644 day6/d18.c create mode 100644 day6/d19.c create mode 100644 day6/d6.c diff --git a/day6/a.out b/day6/a.out new file mode 100755 index 0000000000000000000000000000000000000000..8ec30d0a573ae5086b24bb40a7256fc9d1463f01 GIT binary patch literal 15664 zcmeHOeQX?85r22KYnL{$9VNs`XtHXP$}RH7UokGl%{u`r`mVs zZe5%RiX$gT#xe>YAt9<1Kq{c95fL9EqEPI(N=OC50fa1sz?51!tEEjLg_H^}Gw;o; z_qJz1MS?%rC*97Q-^}m5*|~SS@9t(l+0xz`4uu4_Jn?`)ZLCBg1{u!pq7Dc{)QdH6 z+$!!6w}756F=aQD0IO>A;cQt%cpgaPm0>4`e3ya+OO6mF@>Xl3h04NG(0L%Q08OO( z z3BKwnpMGh84Vxj4Lil;3#PiE$@@I*2V0(Dcj=r7wI*3=P$zg+wK`BrRBia0G7-Du2pdK&E^08 zRd76yT>f7IT!WXteFFf^4}$(ac-@%;$IC;h*dz=?8ToS{`ubybTBPl0JRychplexa zJJS1@)jRN*)fb5mf-N-|O8^c_qZf@S+Zu|1yJhu`My$SgA~G01923K-c*5=z=!NU0 zPV8-O+tXxK>$PsLTHodNYifnn*0s-y#!|8Vc-oGoy7n~B zi?FFpB$b+8ZGB zWnG1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@1ll$W*SWH0&bIN?)N3rC6 z6wlB3o;A;dA~}-$XL0L67RcSzD7Kj zkD`;O@$G@-*TLrHkCB1pMotWk!8{)FoR81@ZkD_sXMg|t{WkI4X*BXA38jEpjq}Ig zGtj~KnO~_X3rk-A3eA4j46!Tl^70RAhzh~-<4Sdp{`r3a7ARqqp8<5@=Zg6GJikBd zEPn@_Vh^9chs;;tXe;YQX)8MOUjhTJ9lC6|`%3qDOFTJfyeyf=@8b=yp$qf*d8X-| z$P%Jl3HQi+mT!Q?%jfSg8R8o*Q+1ff68C9dKJVkoE0sUT$-^+u)q#u{$8Q+QQojn{ zKi(RepWJy^!F>Pc4`apVmAv+pMI8^)fEUP!_aS_rIDWo<;P*3*T`|?Mq(;e4^F(Cy Tsjz3w%|BhM2=DX}e5&{dIJ;6o literal 0 HcmV?d00001 diff --git a/day6/d12.c b/day6/d12.c new file mode 100644 index 0000000..7d1ed2b --- /dev/null +++ b/day6/d12.c @@ -0,0 +1,19 @@ +#include + +int main() +{ + char teacher[] = {'d', 'i', 's', 'e', 'n'}; + printf("%s\n", teacher); // disen + int len = sizeof(teacher); + printf("%d\n", len); // 5 + // for (int i = 0; i < len; i++) + // { + // printf("%c", teacher[i]); + // } + int i = 0; + while (i < len) + { + printf("%c", teacher[i++]); + } + return 0; +} \ No newline at end of file diff --git a/day6/d13.c b/day6/d13.c new file mode 100644 index 0000000..417db80 --- /dev/null +++ b/day6/d13.c @@ -0,0 +1,18 @@ +#include +#include + +int main() +{ + char ask_name[32] = "Jack"; // 结果是 "Jack\0" + printf("%s\n", ask_name); + // sizeof() 统计变量或数组实际分配的内存空间大小,单位是字节 + printf("ask_name size is %ldB\n", sizeof(ask_name)); + // strlen() 函数统计有效的字符个数,不包括 '\0' (遇到第一个 '\0' 就停止统计 ) + printf("ask_name char len is %ld\n", strlen(ask_name)); + + char q_what1[128] = "hi,xiao hua\0,love you!"; + printf("%s\n", q_what1); + printf("%ld \n", strlen(q_what1)); + + return 0; +} \ No newline at end of file diff --git a/day6/d14.c b/day6/d14.c new file mode 100644 index 0000000..f0ca0a1 --- /dev/null +++ b/day6/d14.c @@ -0,0 +1,23 @@ +#include + +int main() +{ + char arr[64] = "hi, disen!"; + // 实现 strlen() 的功能, 统计字符串的长度 + int i = 0; + while (arr[i]) + i++; + printf("%s length: %d\n", arr, i); + + // 反转字符串 + int j = 0; + int mid = i >> 1; // 含义: i / 2, 位运算更快 + while (j < mid) + { + arr[j] ^= arr[i - j - 1]; + arr[i - j - 1] ^= arr[j]; + arr[j] ^= arr[i - j - 1]; + j++; + } + printf("%s\n", arr); +} \ No newline at end of file diff --git a/day6/d15.c b/day6/d15.c new file mode 100644 index 0000000..ded73fb --- /dev/null +++ b/day6/d15.c @@ -0,0 +1,20 @@ +#include +#include + +int main() +{ + char cmd[32] = ""; + printf("请输入一个命令:"); + // scanf() 输入字符串是,遇到第一个空格就停止输入 + // scanf("%s", cmd); // cmd 数组传递的是地址, 不需要加 & 取地址符 + + fgets(cmd, sizeof(cmd), stdin); // 读取一行字符串,遇到回车就停止输入 + // fgets() 获取的字符最后一个是 '\n' 换行符 + cmd[strlen(cmd) - 1] = 0; // 将最后一个字符 '\n' 换成 '\0' 空字符 + + // printf("%s \n", cmd); + // for (int i = 0; i < 32; i++) + printf("%s, %ld\n", cmd, strlen(cmd)); + printf("\n"); + return 0; +} \ No newline at end of file diff --git a/day6/d17.c b/day6/d17.c new file mode 100644 index 0000000..1e190a4 --- /dev/null +++ b/day6/d17.c @@ -0,0 +1,25 @@ +#include +#include + +int main() +{ + // char stu_names[5][32] = {"zhangsan", "lisi", "wangwu", "zhaoliu", "tianqi"}; + char stu_names[5][32]; + int i = 0; + while (i < 5) + { + printf("请输入第 %d 个学生的名字:", i + 1); + fgets(stu_names[i], sizeof(stu_names[i]), stdin); + + stu_names[i][strlen(stu_names[i]) - 1] = '\0'; + + i++; + } + + for (int i = 0; i < 5; i++) + { + printf("%s\n", stu_names[i]); + } + + return 0; +} \ No newline at end of file diff --git a/day6/d18.c b/day6/d18.c new file mode 100644 index 0000000..a2da580 --- /dev/null +++ b/day6/d18.c @@ -0,0 +1,2 @@ +#include +#include diff --git a/day6/d19.c b/day6/d19.c new file mode 100644 index 0000000..cf7fbaa --- /dev/null +++ b/day6/d19.c @@ -0,0 +1,6 @@ +#include +#include + +int main() +{ +} \ No newline at end of file diff --git a/day6/d6.c b/day6/d6.c new file mode 100644 index 0000000..dba1dce --- /dev/null +++ b/day6/d6.c @@ -0,0 +1,33 @@ +#include + +int main() +{ + int nums[5][3] = {0}; + int n; + for (int i = 0; i < 5; i++) + { + printf("请输入第%d个三位数:", i + 1); + scanf("%d", &n); + + int m[] = {100, 10, 1}; + int j = 0; + while (n > 0) + { + nums[i][j] = n / m[j]; + n %= m[j]; + j++; + } + } + + for (int i = 0; i < 5; i++) + { + // 判断这个三位数是否为回文数 + if (nums[i][0] == nums[i][2]) + continue; + for (int j = 0; j < 3; j++) + { + printf("%d ", nums[i][j]); + } + printf("\n"); + } +}