- 博客(85)
- 收藏
- 关注
原创 15.4-PointersOnC-20220510
scanf("[abc]",str);#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>int main(){ char str[30]={}; scanf("%[abc]",str); fputs(str,stdout);return 0;}
2022-05-10 15:54:41
132
原创 13.10.4-PointersOnC-20220429
#include<stdio.h>#include<string.h>int compare_int(void *a,void *b);int compare_str(void *a,void *b);void swap(char *a,char *b,int len);void sort(void *front,int n,int len,int (*pfunc)(void *,void *));void showarr(void *front,int n,ch...
2022-04-29 16:48:34
324
原创 13.10.1-PointersOnC-20220423
#include<stdio.h>#include<ctype.h>int Reroop();void function();int main(int argc,char **argv){ for(fputs("Enter to quit:->",stdout);Reroop();function(),fputs("Enter to quit:->",stdout));return 0;}//int Reroop(){ int ch=0,c...
2022-04-23 22:57:10
450
原创 12.8.7-PointersOnC-20220416
二维单链表#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<string.h>#include<stdlib.h>#include<ctype.h>#define LENWORD 21typedef struct node{ char *word; struct node *next;}Node;typedef struct list{ char le.
2022-04-16 22:00:47
430
原创 12.8.6-PointersOnC-20220405
//初始为空的双链表#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *pfwd; struct node *pbwd; char value[LENWORD];}Node;char *my_fgets(char *p,in...
2022-04-05 00:49:18
166
原创 12.8.5-PointersOnC-20220402
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *link; char value[LENWORD];}Node;char *my_fgets(char *p,int n);int ClearList(Node **p);...
2022-04-02 23:13:44
73
原创 12.8.4-PointersOnC-20220402
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *link; char value[LENWORD];}Node;char *my_fgets(char *p,int n);int ClearList(Node **...
2022-04-02 22:24:35
60
原创 12.8.2-PointersOnC-20220402
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *link; char value[LENWORD];}Node;char *my_fgets(char *p,int n);int ClearList(Node **...
2022-04-02 13:19:23
282
原创 12.8.1-PointersOnC-20220402
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *link; char value[LENWORD];}Node;char *my_fgets(char *p,int n);int ClearList(Node **...
2022-04-02 10:50:31
278
原创 12.7.1-PointersOnC-20220401
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *link; char value[LENWORD];}Node;char *my_fgets(char *p,int n);int ClearList(Node **...
2022-04-01 15:34:48
264
原创 12.3-PointersOnC-20220331
单链表#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *link; char value[LENWORD];}Node;char *my_fgets(char *p,int n);int ClearList(Node **
2022-03-31 16:24:58
711
原创 12.4-PointersOnC-20220328
双链表教材里未使用二级指针,先用双指针法#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENWORD 11typedef struct node{ struct node *pfwd; struct node *pbwd; char value[LENWORD];}Node;char *my_fgets(char *p,int n);/
2022-03-28 22:57:23
1703
原创 12.3-PointersOnC-20220312
在链表中插入新项,并不是肤浅的理解为在前项与后项之间插入新项,而要理解为前项的link指针指向新项,新项的link指针指向后项。
2022-03-12 23:05:30
346
原创 字符处理函数-C-20220310
int getc(FILE *stream)->默认输入为int getchar(void)读取:从指定的流 stream 获取下一个字符(一个无符号字符),并把位置标识符往前移动。返回:以无符号 char 强制转换为 int 的形式返回读取的字符,如果到达文件末尾(feof)或发生读错误(ferror),则返回 EOF。注意:这是一个宏,参数stream不能是有副作用的表达式int fgetc(FILE *stream)读取:从指定的流 stream 获取下一个字符(一个无符号字
2022-03-10 16:59:26
275
原创 11.11.4-PointersOnC-20220309
#include<stdio.h>#include<stdlib.h>typedef struct node{ int num; struct node* node_next;}Node;Node *Initialize_Node(Node *p);Node *Add_Node(Node *p,int n);void Show_Node(Node *p);int main(){ Node *pdata=NULL; for(int i=0;i<100;i++) if(!(pdata
2022-03-09 22:07:45
176
原创 11.11.3-PointersOnC-20220309
#include<stdio.h>#include<stdlib.h>#include<string.h>char *readstring(char *p);int main(){ char *str=NULL; if(str=(char *)calloc(11,sizeof(char))){ fputs("Input the string:->",stdout); if(!readstring(str)) fputs("Reques...
2022-03-09 12:47:24
148
原创 11.11.2-PointersOnC-20220308
#include<stdio.h>#include<stdlib.h>void readinteger(int *p);int main(){ int *arr=(int *)calloc(1,sizeof(int)); if(!arr) return 1; readinteger(arr); fputs("The arr is:",stdout); for(int i=0;i<=*arr;printf("%d ",*(arr+i)),i++); ...
2022-03-08 22:48:30
169
原创 11.11.1-PointersOnC-20220308
#include<stdio.h>#include<stdlib.h>void *my_calloc(size_t count_element,size_t size_element){ void *ptemp=NULL; if(ptemp=malloc(size_element*=count_element)) for(char *pset=(char *)ptemp;size_element--;*pset++=0);return ptemp;}
2022-03-08 21:34:03
68
原创 10.11.1-PointersOnC-20220308
#include<stdio.h>typedef struct{ unsigned short area; unsigned short exchange; unsigned short station;}Number;typedef struct{ unsigned char year; unsigned char month; unsigned char day; unsigned char hour; unsigned char minute; unsigne...
2022-03-08 14:07:52
96
原创 9.14.16-PointersOnC-20220306
额外增加了format和digit完全检测,将检测过程与转化过程分离,经过比较,官方答案更好。
2022-03-06 23:07:58
234
原创 9.14.15-PointersOnC-20220304
#include<stdio.h>#include<string.h>#include<stdlib.h>char *my_fgets(char *p,int n);void dollars_a(char *dest,char *src);void dollars(char *dest,char *src);void dollars1(char *dest,char *src);int main(){ char input[101]={0}; ch...
2022-03-04 16:51:40
217
原创 9.14.14-PointersOnC-20220303
//原先的加密方法太简单,给其加码,原始key中单个字母重复次数使其在key数组补全后与另一个字母进行换位,每个字母重复次数累计值如为奇数,key数组顺时针移动该累计值的位数,偶数为逆时针#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<string.h>#include<ctype.h>char *my_fgets(char *p,int n);int prepare_key(char *key);void encrypt_
2022-03-03 21:57:52
81
原创 9.14.10-PointersOnC-20220302
#include<stdio.h>#include<string.h>#include<ctype.h>int is_palindrome(char *string);int main(int argc,char *argv[]){ char str[]="Madam,I'm Adam"; fputs(is_palindrome(str)?"It's a palindrome.\n":"It's not a palindrome.\n",stdout);...
2022-03-02 12:20:52
148
原创 9.14.9-PointersOnC-20220302
#include<stdio.h>int count_chars(char *str,char *chars);int main(){ char str[]="112223333444445555556666666777777778888888889999999999"; char chars[]="26"; printf("%d\n",count_chars(str,chars));return 0;}//int count_chars(char *str,char *c...
2022-03-02 10:32:34
110
原创 9.14.8-PointersOnC-20220302
#include<stdio.h>char *my_strnchr(char *str,int ch,int which);int main(){ char str[]="81118222833384448555866687778888"; int ch=8+'0'; fputs(my_strnchr(str,ch,2),stdout);return 0;}//char *my_strnchr(char *str,int ch,int which){ char *foun...
2022-03-02 09:48:41
142
原创 9.14.7-PointersOnC-20220302
#include<stdio.h>char *my_strrchr(char *str,int ch);int main(){ char str[]="1234123412341234888"; int ch=2+'0'; fputs(my_strrchr(str,ch),stdout);return 0;}//char *my_strrchr(char *str,int ch){ char *found=NULL; for(;*str;str++) if(*str...
2022-03-02 09:31:00
131
原创 9.14.5-PointersOnC-20220301
#include<stdio.h>#define LEN_DEST 8void my_strncat(char *dest,char *src,int len_dest);int main(){ char src[]={'5','6','7','8','9'}; char dest[LEN_DEST]={'1','2','3','4'}; my_strncat(dest,src,LEN_DEST); fputs(dest,stdout);return 0;}//void...
2022-03-01 22:01:04
78
原创 9.14.2-PointersOnC-20220301
#include<stdio.h>#include<stddef.h>size_t my_strlen(char *str,size_t len_arr);int main(){ char test[99]={'1','2','3','0'}; printf("%u\n",my_strlen(test,99));return 0;}//size_t my_strlen(char *str,size_t len_arr){ size_t len_str=0; ...
2022-03-01 15:57:16
120
原创 9.14.1-PointersOnC-20220301
#include<stdio.h>#include<string.h>#include<ctype.h>typedef struct{ int cntrl; int space; int digit; int lower; int upper; int punct; int nonprint; char str[101]; int count;}Data;char *my_fgets(char *p,int n);void ShowCount(Data *data);int
2022-03-01 13:31:08
80
原创 8.8.8-PointersOnC-20220221
八皇后谜题是编程必修课,对于我一个算法新手来说,刚接触时,想像的是一个二维棋盘,然后从第一行第一列开始布置皇后,当一个皇后放置后,对其攻击范围进行改值,以供后面的皇后放置判断,然后八个皇后放置成功后保存当前二维棋盘,再生成一个新的二维棋盘,第一个皇后从第1行第2列开始布置,保存仓库为一个三维数组。后来一想,不需要保存二维棋盘,只需要保存八个皇后的坐标(结构体)就行,保存仓库缩减为一个二维结构体数组,但是用这种方法却根本计算不出有效的八皇后结果。只能在网上找找相关介绍了,原来棋盘八行八列,八皇后必然行列坐
2022-02-21 16:41:53
358
原创 8.8.5-PointersOnC-20220216
//应该是版本问题,函数形参必须是二级指针,并不能按照书本答案对一级指针进行压扁数组操作//如果必须要将形参定为一级指针,就采用void *的方法#include<stdio.h>#include<stdlib.h>#include<time.h>void matrix_multiply(int **m1,int **m2,int **r,int x,int y,int z);//void matrix_multiply(void *m1,void *m2,void *r,int x,int y
2022-02-16 09:45:23
242
原创 8.8.4-PointersOnC-20220215
#include<stdio.h>#include<stdlib.h>#include<time.h>int Is_Identity_Matrix(int **arr,int num);int main(){ int row=0,ch=0,**matrix=NULL; srand((unsigned int)time(0)); for(fputs("Input the row of matrix:->",stdout);(ch=scanf_s("...
2022-02-15 11:38:25
224
原创 数学-感想-20220215
编程学着学着发现我贫瘠的数学知识已经有些不够用了,听说数学是程序员的蓝条,我准备等C三套学完后从初中数学开始恶补。上学的时候都在混日子,数学、物理、化学没学好,这次就把数学和物理好好补习下。...
2022-02-15 10:38:47
131
原创 8.8.2-PointersOnC-20220214
#include<stdio.h>#include<float.h>float tax_information[3][6]={ {0,23350,56550,117950,256500,DBL_MAX}, {0,3502.5,12798.5,31832.5,81710.5}, {0.15,0.28,0.31,0.36,0.396}};float single_tax(float income);int main(){ printf("%f\n",single_...
2022-02-14 15:02:44
277
原创 8.8.1-PointersOnC-20220214
#include<stdio.h>unsigned char char_value[3][6][4][5]={ {}, { {}, { {}, {0,' '} }, { {}, {}, {0,0,0,'A'}, {0,0,0,0,'x'} }, { {}, {}, {0,0,0xf3} }, { {},{}, {0,0,0,'\n'} } }, { {}, { {}...
2022-02-14 13:48:17
198
原创 7.11.6-PointersOnC-20220211
//思路:每3位对整数进行切片,以动态内存方式生成一个指向含有切片数个元素的指针数组的二级指针,//指针数组中每个指针指向以整数切片转化成的字符串,根据字符串内容及单位所需要的内存大小以动态内存方式生成一个整体的字符串,//将指针数组中每个指针指向的字符串进行拼接,其中加入单位字符串,按顺序存入整体字符串。//代码应该可以再修整下#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<stdlib.h...
2022-02-11 16:53:07
454
原创 右左法则-C-20220210
右左法则不是C标准里面的内容,它是从C标准的声明规定中归纳出来的方法。C标准的声明规则,是用来解决如何创建声明的,而右左法则是用来解决如何辩识一个声明的。究竟右左法则的规律是什么呢?顾名思义,从声明的右边看到左边,下面是左右法则的专业解释:右左法则:首先从最里面的圆括号(应该是未定义的标识符)看起,然后往右看,再往左看。每当遇到圆括号时,就应该掉转阅读方向。一旦解析完圆括号里面所有的东西,就跳出圆括号。重复这个过程直到整个声明解析完毕。...
2022-02-10 13:15:46
329
原创 7.11.5-PointersOnC-20220209
小数打印出来有误差,先这样吧,再弄下去太浪费时间了#include<stdio.h>#include<limits.h>#include<math.h>#include<stdarg.h>void my_printf_integer(int n);void my_printf_string(char *str);void my_printf_float(double n);void my_printf_char(char ch);void
2022-02-09 10:54:56
377
原创 7.11.4-PointersOnC-20220207
#include<stdio.h>#include<stdarg.h>int max_list(int first,...);int main(){ printf("The max is:%d.\n",max_list(0,6,9,5,2,3,2,3,6,985,211,3,-1));return 0;}//int max_list(int first,...){ int max=first,temp=0; va_list var_arg; va_start(var_arg,first)
2022-02-07 11:29:07
410
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人