随笔分类 -  c

摘要://#include "Header.h" #include <stdio.h> #include <stdbool.h> #include <stdlib.h> //exit 函数需要 #include <malloc.h> #define MAXSIZE 20 //队列长度 #define NO 阅读全文
posted @ 2020-06-07 00:19 abel2020 阅读(247) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define NOINFO -1 typedef struct node { int data; struct TNode* L; struct TNode* R; }Node, 阅读全文
posted @ 2020-06-05 20:55 abel2020 阅读(171) 评论(0) 推荐(0)
摘要://冒泡排序,输入一个数组,冒泡排序 #include <stdio.h> #include<time.h> #include<stdlib.h> # define MAXSIZE 10 //要排序数组的长度 #define random(x) (rand()%x) //宏定义随机数函数 //三个参 阅读全文
posted @ 2020-06-04 23:53 abel2020 阅读(132) 评论(0) 推荐(0)
摘要:#include <stdio.h> char A, B, C; han(int, char, char, char); main() { han(4, 'A', 'B', 'C'); } han(n, A, B, C) { if (1 == n) printf("%d %c-%c\n", n, A 阅读全文
posted @ 2020-06-04 11:00 abel2020 阅读(98) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdbool.h> #include <stdlib.h> //exit 函数需要 #include <malloc.h> #define MAXSIZE 8 typedef struct queue { int* arr; //int 类 阅读全文
posted @ 2020-06-03 23:46 abel2020 阅读(171) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <malloc.h> #include <stdbool.h> #include <stdlib.h> typedef struct node //定义节点类型 { int data; struct node* pNext; }*PNODE, 阅读全文
posted @ 2020-06-03 03:35 abel2020 阅读(97) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdbool.h> #include <stdlib.h> //exit 函数需要 #include <malloc.h> typedef struct node { struct node* pNext; int data; }*PNOD 阅读全文
posted @ 2020-06-03 01:27 abel2020 阅读(114) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdbool.h> #include <stdlib.h> //exit 函数需要 typedef struct arr { char* arr_name; int len; //当前数组长度 int maxlen; }*PARR,ARR; 阅读全文
posted @ 2020-05-31 23:32 abel2020 阅读(194) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdbool.h> #include <string.h> struct arr //定义结构体类型 { char* arr_name; int len; int maxlen; }; main() { struct arr array1 阅读全文
posted @ 2020-05-31 18:30 abel2020 阅读(1223) 评论(0) 推荐(0)
摘要:#include <stdio.h> void fun(int** q); void fun2(int** q); main() { int* p; //把p的二级指针传给fun fun(&p); printf("%d", *p); //动态分配内存 fun2(&p); } // void fun( 阅读全文
posted @ 2020-05-31 15:25 abel2020 阅读(140) 评论(0) 推荐(0)
摘要:/*结构体基本练习 */ #include <stdio.h> #include<stdbool.h> #define MALE 0 //男 0 #define FEMALE 1 //女 1 #define MAXNAME 30 //名字数组最多字符数 #define MAXFR 10 //结构体数 阅读全文
posted @ 2020-05-31 04:36 abel2020 阅读(206) 评论(0) 推荐(0)
摘要:/* 该程序练习二维数组 用户输入3组数,每组5个, (3行5列数组) 计算每组平均值 计算每行平均值 计算所有数的平均值 找出所有数的最大值 可以使用如下数组测试 a[3][5] = {{11,12,13,14,15}, {21,22,23,24,15}, {31,32,33,34,35}}; 想 阅读全文
posted @ 2020-05-28 20:27 abel2020 阅读(136) 评论(0) 推荐(0)
摘要://数组倒叙排列 #include<stdio.h> #define SIZE 5 void dao(int*, int size); main() { int a[SIZE]; int i; for (i = 0;i < SIZE;i++) { scanf_s("%d", &a[i]); } da 阅读全文
posted @ 2020-05-28 00:16 abel2020 阅读(118) 评论(0) 推荐(0)
摘要:// #include <stdio.h> int get_input(void); int fac(int); int fac2(int); main() { int input; int ans; int ans2; printf("This progame calculates factori 阅读全文
posted @ 2020-05-27 15:18 abel2020 阅读(262) 评论(0) 推荐(0)
摘要:// 计算a 和b 之间整数的平方和 // 模块化,主程序做流程控制,1个计算函数,1个输入合法函数,1个范围检测函数 #include <stdio.h> #include<stdbool.h> double sum_square(long a, long b); bool bad_limit(l 阅读全文
posted @ 2020-05-27 11:27 abel2020 阅读(168) 评论(0) 推荐(0)
摘要://习题1: 打印a -z #include <stdio.h> main() { int ch[26]; char c; int i; for (i = 0, c = 'a';c <= 'z';c++, i++) // ch[i] = c; for (i = 0;i < 26;i++) // pr 阅读全文
posted @ 2020-05-26 16:40 abel2020 阅读(126) 评论(0) 推荐(0)
摘要://code:1main() { char ch; scanf_s("%c", &ch); while (ch != 'g') { printf("%c", ch); scanf_s("%c", &ch); } } scanf() 依次读入缓存中的数据,并打印,直到 g code 2: main() 阅读全文
posted @ 2020-05-26 14:34 abel2020 阅读(119) 评论(0) 推荐(0)
摘要:// 循环 do while , 利用数组存放输入的数计算平均值 #include <stdio.h> #define N 10 //使用N 常量 main() { int a[10]; float sum = 0.0; float av; int i = 0; do { printf("Input 阅读全文
posted @ 2020-05-26 12:05 abel2020 阅读(472) 评论(0) 推荐(0)
摘要:// 打印A-J 5行 // c语言按行打印,内循环打印行的每个字符,外循环打印第2 3 4 5 行 #include <stdio.h> #define ROWS 5 #define CHARS 10 main() { int row; char ch; for (row = 0;row < RO 阅读全文
posted @ 2020-05-26 11:22 abel2020 阅读(163) 评论(0) 推荐(0)
摘要:1 循环选择 1 do while 出口判断条件是否满足,后面有 “ ;” 至少循环一次 先执行,再判断 如用于先输入 再判断时 for 用于 有初始值,有更新, 循环次数明确,循环计数 while 用于其他 2 i++ 和++i , do while 和 while 区别 // i++ 和++i 阅读全文
posted @ 2020-05-26 11:06 abel2020 阅读(562) 评论(0) 推荐(0)