This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

40
24/03/322.c Normal file
View File

@@ -0,0 +1,40 @@
//
// Created by 李洋 on 2024/3/26.
//
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int min(int a, int b)
{
return a > b ? b : a;
}
int coinChange(int *coins, int coinsSize, int amount)
{
int *dp = (int *)calloc((amount + 1), sizeof(int));
for (int i = 0; i <= amount; i++)
{
dp[i] = amount + 1;
}
dp[0] = 0;
for (int i = 1; i <= amount; ++i)
{
for (int j = 0; j < coinsSize; ++j)
{
if (coins[j] <= i)
{
dp[i] = min(dp[i], dp[i - coins[j]] + 1);
}
}
}
return dp[amount] > amount ? -1 : dp[amount];
}
void run()
{
int a1[3] = {1, 2, 5};
int a2[4] = {3, 7, 405, 436};
int a3[1] = {2};
coinChange(a3, 1, 3);
}

27
24/03/518.c Normal file
View File

@@ -0,0 +1,27 @@
//
// Created by 李洋 on 2024/3/26.
//
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int coinChange(int *coins, int coinsSize, int amount)
{
int *dp = (int *)calloc((amount + 1), sizeof(int));
//memset(dp, 0, sizeof(dp));
dp[0] = 1;
for (int i = 0; i < coinsSize; i++) {
for (int j = coins[i]; j <= amount; j++) {
dp[j] += dp[j - coins[i]];
}
}
return dp[amount];
}
int main()
{
int a1[3] = {1, 2, 5};
int a2[4] = {3, 7, 405, 436};
int a3[1] = {2};
coinChange(a3, 1, 3);
}

12
24/03/quicksort.c Normal file
View File

@@ -0,0 +1,12 @@
#include <stdio.h>
void swap(int* a, int* b) {
int temp = *a;
*a = *b;
*b = temp;
}
void QuickSort(int *arr, int low, int high)
{
}