
数据结构
无
_xwj.
心灵鸡汤之天空飘来五个字——那都不是事。
展开
-
数据结构题
#include <iostream>using namespace std;const int inf=-0x3f;int main(){ int n; cin>>n; int a[n]; int maxn=inf; int f=0; for(int i=0;i<n;i++) { cin>>a[i]; if(a[i]>maxn&&a[i]!=ma原创 2021-10-22 08:17:39 · 80 阅读 · 0 评论 -
【数据结构】单链表的头插法和尾插法
#include <iostream>using namespace std;struct node{ int data; node *next;};//不明白为什么间的指针 //头插法void headlink(int n){ node *head; head= new node; head->data=NULL; head->next=NULL; while(n--) { node *p原创 2022-01-04 00:04:14 · 585 阅读 · 0 评论 -
【数据结构】栈(考点)
#include <bits/stdc++.h>using namespace std;/*栈和队列*///栈/*栈顶 top=-1;为空top=size-1;栈满入栈:top+1出栈:top-1*/const int N=1000;int a[N];int top=-1;void push(int x){//入栈 top++; a[top]=x;}int pop(){//出栈 if(top=-1) cout<<"栈空"原创 2022-01-04 00:14:19 · 668 阅读 · 6 评论 -
【数据结构】排序
#include <bits/stdc++.h>using namespace std;//1.简单直接排序//希尔排序//起泡排序//快速排序//简单选择排序//堆排序//二路归并排序//1依次将带排序序列的每个记录插入到已经排好的序列中知道全部序列都排好序void insertsort(int r[],int n){ int i,j; for(i=2;i<=n;i++) { r[0]=r[i]; for(j原创 2022-01-04 00:05:05 · 243 阅读 · 0 评论