Basic data structuresC--基础数据结构
无
Legendthree
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
字符串数组 Array of strings
编写程序,将M个字符串(每串的长度不超过N)按顺序合并组成一个新的字符串。原创 2023-09-13 23:44:58 · 393 阅读 · 0 评论 -
字符数组应用举例Example character array application
字符串中的剩余字符形成的新字符串存入另一个数组中。输入:******A**B**C**D。输出:A**B**C**D******将该字符串中的下标为偶数的字符删除。原创 2023-09-13 00:34:05 · 135 阅读 · 0 评论 -
递归问题复习
递归原创 2022-12-24 12:45:32 · 158 阅读 · 0 评论 -
修改指针变量与修改一般变量的区别
指针变量原创 2022-12-12 12:00:06 · 127 阅读 · 0 评论 -
指向函数的指针
定义和使用 #include <stdio.h> #include <math.h> int main() { double (*p) (double , double); p = pow; printf("%.5f", p(2, 5)); return 0; } 使用( 指向函数的指针 )的函数 #include <stdio.h> #include <math.h> void op_ar(double *beg, double *end原创 2022-02-12 19:14:39 · 72 阅读 · 0 评论 -
(结构,元素为结构的数组)(指针,使用指针访问数组)
函数接口定义:int update_score(struct student *p, int n, int num, int course, int score);函数使用: pos = update_score(students,n, n um, course, score); (定义一个新数据类型)数据类型所属大类+数据类型名: struct student{ /*学生信息结构定义*/ int num; /* 学号 */ ...原创 2022-02-06 11:52:11 · 112 阅读 · 0 评论 -
C字符型指针的用法案例
输入样例: program g 输出样例: gram #include <stdio.h> char *match(char *s, char ch); /* 函数声明 */ int main(void ) { char ch, str[80], *p = NULL; scanf("%s", str); getchar(); ch = getchar(); if((p = match(str, ch)) != N..原创 2022-02-07 16:28:15 · 171 阅读 · 0 评论 -
元素为指针的数组(每个指针元素指向一个字符串)案例
#include <stdio.h> #include <string.h> int main() { char *color[5] = {"red", "blue", "yellow", "green", "black" }; int i; char v[10];/*数组才能存字符串, 字符变量存一个字符; 一个数字列, 数字*/ int flag = 0; scanf(.原创 2022-02-07 16:37:37 · 183 阅读 · 0 评论 -
数组, 元素为指针,指针指向字符串案例
#include <stdio.h> #include <string.h> void fsort(char *color[ ], int n); int main(void ) { int i; char *pcolor[ ] = {"red", "blue", "yellow", "green", "black"}; void fsort(char *color[ ], int n); fsort(pcolor, 5); /* 调用函数 .原创 2022-02-07 18:50:59 · 144 阅读 · 0 评论 -
多重循环 + 指针训练
可用于任意矩阵的 矩阵乘法函数 #include <stdio.h> void multimatrix(int m, int s, int n, int *p1, int *p2) { int i, k, j; int x = 0; int c[m][n]; for(i = 0; i < m; i++) for(j = 0; j < n; j++) { fo...原创 2022-02-10 22:19:55 · 82 阅读 · 0 评论 -
C -- 操作数组的函数
字符串复制函数 #include <stdio.h> void str_copy(char t[], const char s[]) { int i; while (s[i] != '\0') { t[i] = s[i]; i++; } t[i] = '\0'; for(i = 0; t[i] != '\0'; i++) printf("%c", t[i]); } /*以上函数更紧凑的写法*/ void str_copy_2(char t[], const原创 2022-02-11 16:25:15 · 144 阅读 · 0 评论 -
函数中使用指针访问数组
#include <stdio.h> void del_arr(int n, char *p) { int i; for(i = 0; p[i] != '\0'; i++) p[i] = p[i+n]; for(i = 0; p[i] != '\0'; i++) printf("%c", p[i]); } int main() { char s[] = "reading"; char b[] = "Programmer Peking University Onlin.原创 2022-02-11 15:31:07 · 137 阅读 · 0 评论 -
结构体应用
输入 3 101 Zhang 78 87 85 102 Wang 91 88 90 103 Li 75 90 84 输出 num:102,name:Wang,average:89.67 #include<stdio.h> int main() { struct student { int num; char name[10]; int a; int b; int c; ..原创 2022-02-05 16:57:11 · 549 阅读 · 0 评论 -
动态存储管理
实例:输出0~~(x - 1)的平方数 #include <stdio.h> #include <stdlib.h> int main() { int i; int x; scanf("%d", &x); int *p = (int *)malloc(sizeof(int) * x); for(i = 0; i < x; i++) { p[i] = i * i; printf("%5d", p[i]); } free(p); return原创 2022-02-10 17:10:52 · 91 阅读 · 0 评论
分享