- 博客(5)
- 收藏
- 关注
原创 直接插入排序
void InsertSort(int arr[], int size){ //表示当前要插入元素在数组中的下标 //并且此时i位置的元素一定是要往i之前的位置插入 for (int i = 1; i < size; i++) { //在i之前找插入的位置,因为此时i之前的位置是有序的 int end = i - 1; int key = arr[i]; while (end >= 0 &&...
2021-06-09 13:05:35 40
原创 C++链表的实现
#include <iostream>using namespace std;#include <stdio.h>typedef struct node{ char name[20]; int age; struct node *next;}Student;Student * creatList(int n){ Student * head = new Student; Student * pre = head; fo...
2021-06-04 15:44:36 60
原创 创建链表添加三个同学
#include <iostream>using namespace std;struct student{ char name[20]; int age; student *next;};int main(){ student c = { "seri",18,NULL }; student b = { "bob",20,&c }; student a = {"jack",21,&b}; student *...
2021-06-04 14:14:36 84
原创 反转数组C++
#include <iostream>using namespace std;int main(){ int a[11] = {1,2,3,4,5,6,7,8,9,10,12}; int i = 0; int j = sizeof(a) / sizeof(a[0])-1; while (i < j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; ...
2021-06-01 11:41:20 199
原创 2021-05-27
C++冒泡排序代码实现冒泡排序实现,就当学习吧,两个for循环加判断#include <iostream>using namespace std;void sort(int arr[],int lenth){ for (int i=0; i < lenth; i++) { for (int j=0; j < lenth - i - 1; j++) { if (arr[j] > arr[j...
2021-05-27 14:28:47 37
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人