12 2021 档案

摘要:一、队列:先进先出,模拟银行叫号系统 #include <stdlib.h>#define MAXQ 15typedef struct { int num; long time;}DATA; typedef struct { DATA data[MAXQ]; int head; int tail;} 阅读全文
posted @ 2021-12-27 14:07 雅丽梅 阅读(33) 评论(0) 推荐(0)
摘要:摘自:C语言输入单个字符屏蔽回车符的四种解决方法_weixin_33834137的博客-CSDN博客 C语言的 scanf()/ getchar() 函数在接收输入单个字符时会把上一次输入的回车符号当做这次输入的字符,造成无法正确的识别输入字符数据。 可用以下四种方式回避: 在scanf()中使用' 阅读全文
posted @ 2021-12-27 10:53 雅丽梅 阅读(527) 评论(0) 推荐(0)
摘要:1. File : list.h #ifndef _LIST_H_ #define _LIST_H_#include <stdlib.h>#define LIST_INIT_SIZE 10#define LISTINCREMENT 10 typedef int ElemType;typedef st 阅读全文
posted @ 2021-12-23 20:30 雅丽梅 阅读(103) 评论(0) 推荐(0)
摘要:有时候真的感概,撸码并Debug一天,搞得自己头昏脑胀,结果第二天才发现,原来两行代码的执行顺序错了 -_-! 八皇后问题: 方法一、二维数组 #define N 8int a[N][N] = { 0 };int count = 0; int abs(int x, int y) { return x 阅读全文
posted @ 2021-12-23 08:36 雅丽梅 阅读(38) 评论(0) 推荐(0)
摘要:要求:将 +-*/ 四个运算符,填写到 5 5 5 5 5 = 5,使得等式成立 由于C语言中,没有 python.eval 这样的内置函数,必须自己实现字符串到计算公式的转换。 #include <stdio.h>#include <stdlib.h>#include <conio.h>int m 阅读全文
posted @ 2021-12-17 16:35 雅丽梅 阅读(61) 评论(0) 推荐(0)
摘要:// 一、常用的文件操作函数#define MAX 50void main() { int num, i, array[MAX]; FILE *fp; long offset; for (i = 0; i < MAX; i++) { array[i] = i+10; } if ((fp = fope 阅读全文
posted @ 2021-12-17 16:21 雅丽梅 阅读(34) 评论(0) 推荐(0)
摘要:一、正负数的表示: 计算机只能存储01,正负数的存储有别!以最高位作为符号位:0=正数,1=负数! 正数的原码==反码==补码: EG:10 =》 0000 1010 负数的原码,即将其正数表示的符号位,改为1: EG:-10 =》 1000 1010 负数的反码,即其原码的符号位不变,其他位取反: 阅读全文
posted @ 2021-12-14 21:21 雅丽梅 阅读(224) 评论(0) 推荐(0)
摘要:// 三、判断一个链表是否存在环/* 两个指针:slow.step=1, fast.step=2,在环中两个指针必定相遇 */typedef struct node { int elem; struct node *next;}Node, *NodeList; bool IsExitsLoop(No 阅读全文
posted @ 2021-12-14 14:50 雅丽梅 阅读(46) 评论(0) 推荐(0)
摘要:原文引用:https://blog.csdn.net/qq_42366014/article/details/105000993 #include <stdio.h>#include <stdlib.h>#include <stdbool.h> typedef struct mylist { int 阅读全文
posted @ 2021-12-10 19:45 雅丽梅 阅读(36) 评论(0) 推荐(0)
摘要:/* 1. 指向同一数组的两个指针的差 == 相隔的元素个数,不是字节数int main(void) { int i, t, *p, *q, a[10] = { 1,3,5,7,9,11,13,15,17,19 }; for (p = a, i = 0; i < 10; i++) { printf( 阅读全文
posted @ 2021-12-08 14:11 雅丽梅 阅读(40) 评论(0) 推荐(0)
摘要:/* 1. 求一段字符串中的最长单词 int LTH = 0;int length=0;char result[100]; // 如果放在函数longest中,函数调用完毕,会将其释放int alpha(char c) { if ((c >= 'a' && c <= 'z') || (c >= 'A 阅读全文
posted @ 2021-12-03 14:08 雅丽梅 阅读(11) 评论(0) 推荐(0)
摘要:/* 求两个自然数的最大公约数和最小公倍数int hcd(int u, int v) { int a, b, tmp, result; if (u > v) { tmp = u; u = v; v = tmp; } a = u; b = v; while ((result=b%a) != 0) { 阅读全文
posted @ 2021-12-01 19:17 雅丽梅 阅读(72) 评论(0) 推荐(0)
摘要:/* 结构化程序设计的基本结构:顺序、选择、循环int main(){ int num=100; float f = 3.13145; //printf 格式化输出 printf("num= %-d\n",num); //num= 100 左对齐 printf("num= %+d\n",num); 阅读全文
posted @ 2021-12-01 14:40 雅丽梅 阅读(98) 评论(0) 推荐(0)