摘要: 点击查看代码 //Verify a prime number-Trial division mothod #include<iostream> #include<cmath> using namespace std; int main() { int n; cin >> n; for (int i 阅读全文
posted @ 2024-01-19 13:32 bituion 阅读(9) 评论(0) 推荐(0)
摘要: 点击查看代码 //Convert a number from decimal to binary #include<iostream> using namespace std; struct node { int data; node* next; }; node* A; void insert(i 阅读全文
posted @ 2024-01-19 13:09 bituion 阅读(14) 评论(0) 推荐(0)
摘要: 点击查看代码 //Quick sort #include<iostream> using namespace std; int partition(int A[],int start,int end) { int pivot = A[end];//默认选取末尾为主元 int pIndex = sta 阅读全文
posted @ 2024-01-19 11:52 bituion 阅读(19) 评论(0) 推荐(0)
摘要: 点击查看代码 //Stack-link list implementation #include<iostream> using namespace std; struct node { int data; node* next; }; node* top; void push(int x) { n 阅读全文
posted @ 2024-01-19 07:51 bituion 阅读(22) 评论(0) 推荐(0)
摘要: 点击查看代码 //Merge sort #include<iostream> using namespace std; void merge(int L[], int R[], int A[], int nL, int nR) {//将两个已排序数组合并填入 int i = 0, j = 0, k 阅读全文
posted @ 2024-01-18 17:46 bituion 阅读(17) 评论(0) 推荐(0)
摘要: 点击查看代码 //Insertion sort #include<iostream> using namespace std; void insertionsort(int A[], int n) { int value, hole;//value表示插入值,hole表示插入位置 for (int 阅读全文
posted @ 2024-01-18 10:56 bituion 阅读(26) 评论(0) 推荐(0)
摘要: 点击查看代码 //Bubble sort #include<iostream> using namespace std; void bubblesort(int A[], int n) { for (int k = 1; k < n; k++) {//遍历n-1次,使索引1至索引n-1完成排序,索引 阅读全文
posted @ 2024-01-18 08:29 bituion 阅读(25) 评论(0) 推荐(0)
摘要: 点击查看代码 //Selection sort #include<iostream> using namespace std; void selectionsort(int A[], int n) { for (int i = 0; i < n - 1; i++) {//从索引0开始排序至索引n-2 阅读全文
posted @ 2024-01-18 07:38 bituion 阅读(17) 评论(0) 推荐(0)
摘要: 点击查看代码 //Stack-array based implementation #include<iostream> using namespace std; #define MAX_SIZE 101 int A[MAX_SIZE];//globle int top = -1;//globle 阅读全文
posted @ 2024-01-17 21:05 bituion 阅读(26) 评论(0) 推荐(0)
摘要: 点击查看代码 //Doubly linked list #include<iostream> using namespace std; struct node { int data; node* next; node* prev; };//定义双向链表结构体 node* A; node* getne 阅读全文
posted @ 2024-01-17 19:52 bituion 阅读(18) 评论(0) 推荐(0)