摘要: 背景 有以下需求 1.假设我们只知道 A 的地址,struct1 的地址是不知道的 2.那么如何通过 A 的地址去找到 struct1 的地址呢? #include <stdio.h> typedef struct MyStruct1 { int a ; char b ; int c ; } Str 阅读全文
posted @ 2021-12-14 21:02 想想就很离谱 阅读(354) 评论(0) 推荐(0) 编辑
摘要: 目的 玩点花哨儿的东西 通过函数指针寻址到另一个函数地址并调用 上代码 #include <stdio.h> typedef void(*Type)(); // 测试函数1 void Fun1() { printf("I am Fun1\n"); } // 测试函数2 void Fun2() { p 阅读全文
posted @ 2021-12-14 17:57 想想就很离谱 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 要求 用C语言判断某年某月是否为闰年该月有多少天。 判断是否闰年满足以下其中一个条件即可 1.该年份能被 4 整除同时不能被 100 整除。 2.该年份能被400整除。 上代码 #include <stdio.h> // 主函数 int main(int argc, char **argv) { i 阅读全文
posted @ 2021-12-14 17:04 想想就很离谱 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 要求 用C语言打印9x9乘法表 上代码 #include <stdio.h> // 打印99乘法表 void printMultiplication99() { for (int i = 1; i <= 9; ++i) { for (int j = 1; j <= i; ++j) { printf( 阅读全文
posted @ 2021-12-14 15:51 想想就很离谱 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 要求 用C语言打印一个菱形图案。 上代码 #include <stdio.h> // 打印菱形 void printRhombus(int N) { /// 1.上三角形 for (int n = 1; n <= N; ++n) { // 1.打空格 for (int i = 0; i < N - 阅读全文
posted @ 2021-12-14 15:09 想想就很离谱 阅读(1038) 评论(0) 推荐(0) 编辑
摘要: 要求 C语言比较三个数大小并求出最大最小值 上代码 #include <stdio.h> // 返回最大值 int compare1(int a, int b) { return a > b ? a : b; } // 返回最小值 int compare2(int a, int b) { retur 阅读全文
posted @ 2021-12-14 14:01 想想就很离谱 阅读(2213) 评论(0) 推荐(0) 编辑
摘要: 要求 在忽略其他一些情况下,把整型 a 和 b 的值互换。 应该比较简单,直接上代码。 小二上代码 #include <stdio.h> // 主函数 int main(int argc, char **argv) { int a = 50; int b = 20; printf("交换前: a = 阅读全文
posted @ 2021-12-14 13:27 想想就很离谱 阅读(6698) 评论(0) 推荐(0) 编辑
摘要: 要求 // 要求:将 str 中重复项去除 string str{"A1","A8","A2","A2","A8","A3","A1","A4"}; 小二上代码 #include <iostream> #include <string> #include <vector> #include <alg 阅读全文
posted @ 2021-12-14 11:18 想想就很离谱 阅读(491) 评论(0) 推荐(0) 编辑