数据结构
Yet again
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
MPI并行程序编写与调试(MPI矩阵-向量乘法)
1、编写程序 vim mpi_mat_vect_time.c 2、编译、运行OpenMP并行程序(MPI矩阵-向量乘法) mpicc -g -Wall -o mpi_mat_vect_time mpi_mat_vect_time.c mpiexec -n 4 ./mpi_mat_vect_time /* File: mpi_mat_vect_time.c * * Purpose: Implement parallel matrix-vector multiplication using *原创 2021-12-12 17:00:29 · 1633 阅读 · 0 评论 -
指向结构体数据的指针作函数参数。
指向结构体数据的指针作函数参数。 #include <stdio.h> struct stdtp { int num; char name[10]; float score; }; void output (struct stdtp *p) { printf("%d\t%s\t%5.1f\n", p->num, p->name, p->score); } main() { struct stdtp stu[3]={{1,"Zhao",90.0},{2,"Qian",89.5}原创 2021-12-12 16:50:14 · 470 阅读 · 0 评论 -
使用指向结构体数组的指针来访问结构体数组元素。
使用指向结构体数组的指针来访问结构体数组元素。 #include<stdio.h> struct stdtp { int num; char name[10]; float score; } main() { struct stdtp stu[3]={{1, "Wang", 90.0}, {2, "Qian", 89.5}, {3, "Sun", 85.0}}; struct stdtp *p; int i; p=stu; printf("Num\t原创 2021-12-12 16:49:12 · 2394 阅读 · 0 评论 -
使用指向结构体变量的指针来访问结构体变量的各个成员。
使用指向结构体变量的指针来访问结构体变量的各个成员。 #include <stdio.h> struct stdtp { int num; char name[10]; float score; }; main() { struct stdtp s={1, "Wang", 89.5}, *p=&s; printf("Num:%d\n", p->num); printf("Name:%s\n", p->name); printf("Score:%5.1f\n", p->原创 2021-12-12 16:48:05 · 1411 阅读 · 0 评论 -
编写程序,利用结构体数组存储和显示三个学生的信息。
编写程序,利用结构体数组存储和显示三个学生的信息。 #include<stdio.h> struct stdtp { int num; char name[10]; float score; } stu[3]={{1, "Zhao", 90}, {2, "Qian", 89.5}, {3, "Sun", 85}}; main() { int i; printf("Num\tName\tScore\n"); for(i=0; i<3; i++)原创 2021-12-12 16:47:00 · 2704 阅读 · 0 评论 -
查找链表中倒数第k个位置上的结点
1)算法的基本设计思想: 问题的关键是设计一个尽可能高效的算法,通过链表的一趟遍历,找到倒数第k个结点的位置。算法的基本设计思想:定义两个指针变量p和q,初始时均指向头结点的下一个结点(链表的第一个结点)。p指针沿链表移动,当p指针移动到第k个结点时,q指针开始与p指针同步移动;当p指针移动到最后一个结点时,q指针所指示结点为倒数第k个结点。以上过程对链表仅进行一遍扫描。 2)算法的详细实现步骤: ① count=0,p和q指向链表表头结点的下一个结点; ② 若p为空,转⑤; ③ 若count等于k,则q指原创 2021-12-08 19:10:47 · 665 阅读 · 0 评论 -
利用二叉树前序遍历方法创建一棵二叉树(前序建立二叉树是输入的序列是:AB#D##C#E## ),然后对该二叉树进行前序遍历(非递归),并输出遍历结果
利用二叉树前序遍历方法创建一棵二叉树(前序建立二叉树是输入的序列是:AB#D##C#E## ),然后对该二叉树进行前序遍历(非递归),并输出遍历结果 #include <stdio.h> #include <stdlib.h> typedef struct node { char data; struct node *lchild,*rchild; }binnode; typedef binnode *bintree; bintree creatbintree() { ch原创 2021-12-08 19:08:48 · 2647 阅读 · 2 评论 -
C语言之顺序表中值为 X 的结点个数
#include "stdio.h" #define max 100 typedef struct{ int a[max]; int size; } sequence_list; int search(sequence_list *c,int x) // 用整形返回值类型的自定义函数,返回值即 x 的节点数 { int i,j=0; for(i=0;i<c->size;i++) { if(c->a[i]==x) { j++; } } return原创 2021-12-08 19:06:28 · 4271 阅读 · 1 评论 -
使用递归与非递归方式,实现顺序表中所有元素的逆转。
#include<iostream> using namespace std; typedef int ElemType; typedef struct LNode{ ElemType data; struct LNode *next; }LNode, *LinkList; //链表的初始化 void InitList(LinkList &L){ L = new LNode; L->next = NULL; } //使用尾插法建立单链表 LinkList tailIn原创 2021-11-30 23:06:59 · 897 阅读 · 0 评论 -
多项式相加之C语言
#include<stdio.h> #include<stdlib.h> struct Node; typedef struct Node *PNode; struct Node{ float coef; int exp; PNode next; }; PNode createpoly() { PNode h = NULL, p = NULL, q; int a,b,e; float c; printf("请输入系数和指数(指数从大到小):\n"原创 2021-11-30 23:03:46 · 998 阅读 · 0 评论 -
实现顺序表的就地倒置
#include"stdio.h" #include"stdlib.h" #include"conio.h" #define MAXSIZE 100 typedef int datatype; typedef struct{ datatype data[MAXSIZE]; int length; }sequence_list; void reverse(sequence_list *L) { int t,i,j; i=0; j=L->length-1; while原创 2021-11-30 23:01:46 · 1988 阅读 · 0 评论 -
利用二叉树前序遍历
#include "stdio.h" #include "stdlib.h" typedef char TElemType; typedef struct BiTNode { TElemType data; struct BiTNode *lchild, *rchild; }BiTNode,*BiTree; void CreateBiTree(BiTree &T) { // 构造二叉链表表示的二叉树 T 。以 # 表示空树 TElemType ch; scanf("%c",&原创 2021-11-30 22:59:42 · 427 阅读 · 0 评论 -
高精度数字的加法(C语言)
分析: 此时数字的范围超出了最大整形范围,那我们应该用什么方式来存储这个数字呢? 我们首先想到了数组,可以用字符数组的每一个元素存储整数的每一个数;这样我们就可以将两个数字存放入我们的两个字符串中。 在进行运算前,需要明确下面几点: 1.字符转数字,减去‘0’;数字转字符加上‘0’;(这里是ascll码) 2.进位考虑 3.最高位时进位判断 有了这些基础,我们就可以尝试写代码啦! //直接对字符数组进行操作 #include<stdio.h> #include<string.h> #转载 2021-11-27 22:12:55 · 336 阅读 · 0 评论 -
查找链表中倒数第k个位置上的结点
1)算法的基本设计思想: 问题的关键是设计一个尽可能高效的算法,通过链表的一趟遍历,找到倒数第k个结点的位置。算法的基本设计思想:定义两个指针变量p和q,初始时均指向头结点的下一个结点(链表的第一个结点)。p指针沿链表移动,当p指针移动到第k个结点时,q指针开始与p指针同步移动;当p指针移动到最后一个结点时,q指针所指示结点为倒数第k个结点。以上过程对链表仅进行一遍扫描。 2)算法的详细实现步骤: ① count=0,p和q指向链表表头结点的下一个结点; ② 若p为空,转⑤; ③ 若count等于k,则q指原创 2021-11-14 00:46:58 · 1716 阅读 · 1 评论
分享