自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(133)
  • 收藏
  • 关注

原创 7-36 复数四则运算 (15 分)

代码:#include <stdio.h>#include <math.h> void put(double a1, double b1, double a2, double b2, double up, double down, char op){ if (b1 < 0 && b2 < 0)printf("(%.1lf-%.1lfi) %c (%.1lf-%.1lfi) = ", a1, fabs(b1), op, a2, fabs(b2)..

2021-02-17 09:41:35 185

原创 7-18 二分法求多项式单根 (20 分)

代码:#include <stdio.h>double a0, a1, a2, a3;double f (double x){ double result = a0 + a1 * x + a2 * x * x + a3 * x * x * x; return result; } double BinArray(double a, double b){ while (b - a > 0.001) { double mid = (a + b) / 2; doubl.

2021-02-14 17:46:02 133

原创 6-13 折半查找 (15 分)

代码:int BinArray(SSTable T, int start, int end, KeyType k){ int mid = (start + end) / 2; while (start <= end) { if (T.R[mid].key == k) return mid; else if (T.R[mid].key > k) return BinArray(T, start, mid - 1, k); else return BinArray(T, m...

2021-02-14 16:21:45 146

原创 6-11 求自定类型元素序列的中位数 (25 分)

代码:ElementType Median( ElementType A[], int N ){ int i = 0, j = 0; ElementType mid = N / 2; while (mid > 0) { for (i = mid; i < N; i++) { j = i - mid; while (j >= 0 && A[i] < A[j]) { ElementType tmp = A[i]; A..

2021-02-14 15:46:39 106

原创 练习6.2 邻接表存储图的广度优先遍历 (20分)

练习6.2 邻接表存储图的广度优先遍历 (20分)代码:void BFS ( LGraph Graph, Vertex S, void (*Visit)(Vertex) ){ int node[Graph->Nv], start = 0, end = 0; node[end++] = S; while (start < end) { Visited[node[start]] = true; Visit(node[start]); PtrToAdjVNo

2020-08-19 18:47:05 948

原创 练习6.1 邻接矩阵存储图的深度优先遍历 (20分)

练习6.1 邻接矩阵存储图的深度优先遍历 (20分)代码:void DFS( MGraph Graph, Vertex V, void (*Visit)(Vertex) ){ Visited[V] = true; (*Visit)(V); int i = V, j = 0; for (j = 0; j < Graph->Nv; j++)//有可能都连在了一个点上,所以用Nv { if (Graph->G[i][j] == 1 && Visit

2020-08-19 17:50:13 908

原创 习题5.10 线性探测法的查找函数 (20分)

习题5.10 线性探测法的查找函数 (20分)代码:Position Find( HashTable H, ElementType Key ){ int index = Hash(Key, H->TableSize), count = 0; while (count != H->TableSize) { if (H->Cells[index].Info == Empty || H->Cells[index].Info == Deleted || H->Ce

2020-08-19 16:09:13 1100

原创 习题4.3 是否二叉搜索树 (25分)

习题4.3 是否二叉搜索树 (25分)代码:int mid = -1;//第一次出来的是最左子树,其值是最小的 bool IsBST ( BinTree T ){ if (T == NULL) return true;//为空的时候是二叉搜索树 IsBST(T->Left);//判断左子树 if (T->Data < mid) return false;//如果根节点小于左子树上的元素返回false else mid = T->Data;//不是的话,记录

2020-08-19 15:16:27 248

原创 实验8-2-3 删除字符 (20分)

实验8-2-3 删除字符 (20分)代码:void delchar( char *str, char c ){ char *string = str; int i = 0, count = 0; while (*(string + i) != '\0') { if (*(string + i) != c) { *(str + count) = *(string + i); count++; } i++; } *(str + count) = '\0';//点睛之笔

2020-08-19 10:12:20 190

原创 实验8-1-8 报数 (20分)

实验8-1-8 报数 (20分)代码://这个是记录相应位置第几个出去的,而不是哪个数出去 void CountOff( int n, int m, int out[] ){ int nums[n], index = 1, i = 0, cnt = 1; for (i = 0; i < n; i++) nums[i] = i + 1;//记录每个人的下标位置 while (cnt <= n) { for (i = 0; i < n; i++) { if (n

2020-08-19 10:03:04 177

原创 实验8-1-7 数组循环右移 (20分)

实验8-1-7 数组循环右移 (20分)代码:int ArrayShift( int a[], int n, int m ){ m = m % n; int i = 0, c[n], count = m; for (i = 0; i < n - m; i++) c[count++] = a[i]; count = 0; for (i = n - m; i < n; i++) c[count++] = a[i]; for (i = 0; i < n; i++) a[i]

2020-08-19 09:41:01 276

原创 实验8-1-6 函数实现字符串逆序 (15分)

实验8-1-6 函数实现字符串逆序 (15分)代码:void f( char *p ){ int i = 0, length = 0; for (i = 0; *(p + i) != '\0'; i++) { length++; } for (i = 0; i < length / 2; i++) { char mid = *(p + i); *(p + i) = *(p + length - i - 1); *(p + length - i - 1) = mid

2020-08-19 09:26:41 573

原创 实验5-7 使用函数求1到10的阶乘和 (10分)

实验5-7 使用函数求1到10的阶乘和 (10分)代码:double fact( int n ){ int i = 1, mul = 1; for (i = 1; i <=n; i++) mul *= i; return mul;}

2020-08-04 08:20:09 315

原创 实验5-8 使用函数统计指定数字的个数 (15分)

实验5-8 使用函数统计指定数字的个数 (15分)代码:int CountDigit( int number, int digit ){ int count = 0; if (number < 0) number *= (-1); if (number == 0) return 1; while (number > 0) { if (number % 10 == digit) count++; number /= 10; } return count;}...

2020-08-04 08:19:59 207

原创 实验5-6 使用函数判断完全平方数 (10分)

实验5-6 使用函数判断完全平方数 (10分)代码:int IsSquare( int n ){ int i = 0; for (i = 0; i <= n; i++) { if (i * i == n) return 1; } return 0;}

2020-08-03 09:54:53 1243

原创 实验5-5 使用函数求素数和 (20分)

实验5-5 使用函数求素数和 (20分)代码:int prime( int p ){ if (p <= 1) return 0; if (p == 2) return 1; int i = 2; for (i = 2; i < p; i++) { if (p % i == 0) return 0; } return 1;}int PrimeSum( int m, int n ){ int sum = 0, i = 0; for (i = m; i <

2020-08-03 09:51:33 763

原创 实验5-4 使用函数计算两点间的距离 (10分)

实验5-4 使用函数计算两点间的距离 (10分)代码:double dist( double x1, double y1, double x2, double y2 ){ double dis = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); return dis;}

2020-08-03 09:40:42 182

原创 实验5-3 使用函数求奇数和 (15分)

实验5-3 使用函数求奇数和 (15分)代码:int even( int n ){ if (n % 2 == 0) return 1; return 0;}int OddSum( int List[], int N ){ int i = 0, sum = 0; for (i = 0; i < N; i++) { if (even(List[i]) == 0) sum += List[i]; } return sum;}...

2020-08-03 09:37:47 532

原创 实验5-2 符号函数 (10分)

实验5-2 符号函数 (10分)代码:int sign( int x ){ if (x > 0) return 1; else if (x == 0) return 0; else return -1;}

2020-08-03 09:30:43 313

原创 实验5-1 使用函数计算两个复数之积 (10分)

实验5-1 使用函数计算两个复数之积 (10分)代码:void complex_prod( double x1, double y1, double x2, double y2 ){ result_real = x1 * x2 - y1 * y2; result_imag = x1 * y2 + x2 * y1;}

2020-08-03 09:28:19 247

原创 实验2-4-5 简单实现x的n次方 (10分)

实验2-4-5 简单实现x的n次方 (10分)代码:double mypow( double x, int n ){ int i = 0; double mul = 1; for (i = 0; i < n; i++) mul *= x; return mul; }

2020-08-03 09:24:24 447

原创 实验2-4-1 统计各位数字之和是5的数 (20分)

实验2-4-1 统计各位数字之和是5的数 (20分)代码:int is( int number ){ int sum = 0; while (number > 0) { sum += (number % 10); number /= 10; } if(sum == 5) return 1; return 0;}void count_sum( int a, int b ){ int count = 0, sum = 0, i = 0; for (i = a; i &l

2020-08-03 09:20:31 479

原创 496. 下一个更大元素 I

496. 下一个更大元素 I代码:class Solution { public int[] nextGreaterElement(int[] nums1, int[] nums2) { List<Integer> list = new ArrayList<>(); for (int i = 0; i < nums1.length; i++) { int j = 0;

2020-08-03 09:15:44 89

原创 1021. 删除最外层的括号

1021. 删除最外层的括号代码:class Solution { public String removeOuterParentheses(String S) { StringBuffer str = new StringBuffer(); int countL = 0, countR = 0; for (int i = 0; i < S.length(); i++) { if (S.charAt(

2020-08-03 09:15:30 69

原创 1047. 删除字符串中的所有相邻重复项

1047. 删除字符串中的所有相邻重复项代码:class Solution { public String removeDuplicates(String S) { Stack<Character> stack = new Stack(); for (int i = 0; i < S.length(); i++) { if (stack.empty() || stack.peek() != S.charAt

2020-08-02 11:42:10 80

原创 剑指 Offer 30. 包含min函数的栈

剑指 Offer 30. 包含min函数的栈代码:class MinStack { Stack<Integer> stack1, stack2; public MinStack() { stack1 = new Stack<>(); stack2 = new Stack<>(); } public void push(int x) { stack1.add(x); if

2020-08-02 11:26:05 77

原创 剑指 Offer 09. 用两个栈实现队列

剑指 Offer 09. 用两个栈实现队列代码:class CQueue { Deque<String> deque; public CQueue() { deque = new ArrayDeque<>(); } public void appendTail(int value) { deque.addLast(value + ""); } public int deleteHead() {

2020-08-02 10:56:06 66

原创 习题9-5 通讯录排序 (20分)

习题9-5 通讯录排序 (20分)代码:#include <stdio.h>#include <stdlib.h>struct friends { char name[11]; int birth; char number[18];} Friends[10];int main(){ int i = 0, j = 0, z = 0, n = 0; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%

2020-08-02 10:07:53 368

原创 习题9-4 查找书籍 (20分)

习题9-4 查找书籍 (20分)代码:#include <stdio.h>#include <string.h>int main(){ int n = 0, i = 0; double min = 0, max = 0; char minName[31], maxName[31]; scanf("%d\n", &n); for (i = 0; i < n; i++) { char name[31]; double price = 0;

2020-08-02 09:22:11 1138 3

原创 习题9-3 平面向量加法 (15分)

习题9-3 平面向量加法 (15分)代码:#include <stdio.h>#include <math.h>int main(){ double x1 = 0, y1 = 0, x2 = 0, y2 = 0; scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2); double x = x1 + x2; double y = y1 + y2; if (fabs(x) < 0.05) x

2020-08-02 09:08:12 263

原创 习题9-1 时间换算 (15分)

习题9-1 时间换算 (15分)代码:#include <stdio.h>int main(){ char time[9]; int i = 0, hh = 0, mm = 0, ss = 0, n = 0; gets(time); scanf("%d", &n); for (i = 0; i < 2; i++) hh = hh * 10 + (time[i] - '0'); for (i = 3; i < 5; i++) mm = mm * 10 +

2020-08-02 08:53:58 239

原创 习题8-10 输出学生成绩 (20分)

习题8-10 输出学生成绩 (20分)代码:#include <stdio.h>int main(){ int n = 0, i = 0; double score = 0, min = 0, max = 0, sum = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf", &score); if (i == 0) { min = score; max = score;

2020-08-02 08:44:42 340

原创 447. 回旋镖的数量

447. 回旋镖的数量代码:class Solution { public int numberOfBoomerangs(int[][] points) { int count = 0; for (int i = 0; i < points.length; i++) { Map<Integer, Integer> dis = new HashMap<>(); for (

2020-08-02 08:35:56 80

原创 习题8-7 字符串排序 (20分)

习题8-7 字符串排序 (20分)代码:#include <stdio.h>#include <string.h>int main(){ char str[5][81]; int i = 0, j = 0; for (i = 0; i < 5; i++) scanf("%s", &str[i]); for (i = 0; i < 4; i++) { for (j = i + 1; j < 5; j++) { if (str

2020-08-02 08:32:48 196

原创 720. 词典中最长的单词

720. 词典中最长的单词代码:class Solution { public String longestWord(String[] words) { Set<String> word = new HashSet<>(); String string = null; int max = 0; for (int i = 0; i < words.length; i++) word.add(words[

2020-08-01 16:58:10 95

原创 463. 岛屿的周长

463. 岛屿的周长代码:class Solution { public int islandPerimeter(int[][] grid) { int C = 0; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length; j++) { if (grid[i]

2020-08-01 16:06:57 68

原创 299. 猜数字游戏

299. 猜数字游戏代码:class Solution { public String getHint(String secret, String guess) { StringBuffer str = new StringBuffer(); int[] secrets = new int[10]; int[] guesses = new int[10]; int cows = 0, bulls = 0; for

2020-08-01 15:48:33 84

原创 204. 计数质数

204. 计数质数代码:class Solution { public int countPrimes(int n) { boolean isPrime[] = new boolean[n + 1]; for (int i = 1; i <=n; i++) isPrime[i] = true; if (n <= 1) return 0; if (n == 2) return 1; int count =

2020-08-01 11:16:50 97

原创 习题7-8 字符串转换成十进制整数 (15分)

习题7-8 字符串转换成十进制整数 (15分)代码:#include <stdio.h>int main(){ int sum = 0, sign = 1, flag = 0; char cha; cha = getchar(); while (cha != '#') { if (cha >= '0' && cha <= '9') { sum = sum * 16 + (cha - '0'); flag = 1; } else

2020-08-01 10:13:39 330

原创 习题7-7 字符串替换 (15分)

习题7-7 字符串替换 (15分)代码:#include <stdio.h>int main(){ char reg[26] = {'Z', 'Y', 'X', 'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A'}; char str[81]; int i = 0; gets(str); for (i

2020-08-01 09:48:52 368

A3C_continuous_action.py

A3C_continuous_action.py

2023-04-04

对边缘计算的大概理解!

研究生第一次组会,确定方向啦,是要研究边缘计算的人了

2022-11-13

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除