2021年10月11日
摘要:
1.在一个非递减有序的线性表中,有数值相同的元素存在。若存储方式为单链表,设计算法去掉数值相同的元素,使链表中不再有重复元素,要求算法时间复杂度为O(N)。例如:算法输入链表为(19,26,26,32,50,62,62,62,89),则输出为(19,26,32,50,62,89)。作答时,给出必要的
阅读全文
posted @ 2021-10-11 22:06
学群
阅读(130)
推荐(0)
2021年9月15日
摘要:
#include <iostream> using namespace std; void Fibonacci(int n) { unsigned int a = 1, b = 1; cout << a << '\t' << b << '\t'; for (int t = 3; t <= n; ++
阅读全文
posted @ 2021-09-15 21:57
学群
阅读(487)
推荐(0)
摘要:
#include <iostream> using namespace std; int Fibonacci(int n) { if (n == 1 || n == 2) return 1; else return Fibonacci(n - 1) + Fibonacci(n - 2); } int
阅读全文
posted @ 2021-09-15 21:28
学群
阅读(555)
推荐(0)
摘要:
#include <iostream> #include <iomanip> using namespace std; void GetPrimenumber() { cout<<"求小于正整数n的素数,请输入正整数:"; int n; cin >> n; int c = 0; int h = 0;
阅读全文
posted @ 2021-09-15 20:24
学群
阅读(55)
推荐(0)
2021年8月30日
摘要:
//面对对象风格的单链表排序.//现在的主要问题是,排序的列表中不能出现0,原因是与NULL冲突. #include <iostream> using namespace std; const long int MAX = 2147483647; //长整形的最大值,即 (2^31)-1,在当前编译
阅读全文
posted @ 2021-08-30 21:49
学群
阅读(41)
推荐(0)
2021年8月20日
摘要:
使用了两种错排问题算法,并对其进行了时间分析。 #include <iostream> #include <ctime> using namespace std; int power(int a, int b) { int sum = a; while (b > 1) { sum *= a; --b
阅读全文
posted @ 2021-08-20 19:26
学群
阅读(251)
推荐(0)
2021年8月10日
摘要:
结构体节点: typedef struct student { int num; //学号 int score; //分数 char name[20]; struct student *next;//指针域 }STU; demo: 1、 void link_delete_num(STU **p_he
阅读全文
posted @ 2021-08-10 11:08
学群
阅读(443)
推荐(0)
2021年7月15日
摘要:
#include <iostream> using namespace std; void GetPrimenumber() { cout<<"求小于正整数n的素数,请输入正整数:"; int n; cin >> n; int c = 0; int h = 0; cout << endl; for
阅读全文
posted @ 2021-07-15 00:40
学群
阅读(57)
推荐(0)
摘要:
#include <iostream> #include<cmath> using namespace std; void GetSelfpowerNumber() { cout << "求小于正整数n的自幂数,请输入正整数:" << endl; long int c , n = 0 , h , k
阅读全文
posted @ 2021-07-15 00:25
学群
阅读(48)
推荐(0)
2021年7月14日
摘要:
//现在的主要问题是,排序的列表中不能出现0,原因是与NULL冲突。 #include <stdio.h> #include <stdlib.h> #define MAX 999999 typedef struct LNode//重命名struct LNode为LNode { int data; L
阅读全文
posted @ 2021-07-14 15:45
学群
阅读(859)
推荐(0)