- 博客(4)
- 收藏
- 关注
原创 使用qsort对字符串进行排序
排序字符串,按长度排序,如果长度一样则按字典顺序排序。需要注意的是cmpfun传入的两个参数的是指向数组元素的指针,即传入的a,b实际是char**类型。#include <stdio.h>#include <stdlib.h>#include <string.h>int cmpfun(const void *a,const void *b){ char *str1=*(char**)a; char *str2=*(char**)b;
2021-09-14 18:19:36
3181
2
原创 C语言读取带有逗号的数组
做小米笔试的时候遇到了要直接写输入读取带逗号的数组,差点没写出来#include <stdio.h>#include <stdlib.h>#include <string.h>void main(){ int n,len; int *arr; char tmp[10]; char str[1000]; scanf("%d", &n); //数组大小 arr = (int*)malloc(sizeof(int) * n); scanf
2021-09-01 21:03:52
2336
原创 01背包问题/多重背包问题
#include <stdio.h>#include <stdlib.h>void zobag() { int m, n; scanf("%d %d", &m, &n); int* weight = (int*)malloc(sizeof(int) * (n + 1)); int* value = (int*)malloc(sizeof(int) * (n + 1)); int** dp = (int**)malloc(sizeof(int*) * .
2021-08-23 16:05:35
140
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人