-
高级语言程序设计课程第十次个人作业
这个作业属于哪个课程:https://edu.cnblogs.com/campus/fzu/gjyycx 这个作业的要求在:https://edu.cnblogs.com/campus/fzu/gjyycx/homework/15596 姓名:黄思哲 学号:102500433 1. 2. 3. 4. -
贪心算法分析选点问题
一、 贪心算法分析选点问题 先明确选点问题标准定义(作业高频考点):给定一条直线上的 $n$ 个点,坐标分别为 $x_1 \le x_2 \le \dots \le x_n$,现需选取若干个点,使得每个点都能被某个选取的点覆盖,覆盖范围为选取点坐标的 $[a, a+1]$ 区间(区间长度固定为1), -
实验6
task1.c task1.c 1 #include <stdio.h> 2 #include <string.h> 3 #define N 3 4 typedef struct student { 5 int id; 6 char name[20]; 7 char subject[20]; 8 d -
实验六
实验任务1 contestant.hpp #pragma once #include <iomanip> #include <iostream> #include <string> struct Contestant { long id; // 学号 std::string name; // 姓名 -
任务6
任务1: #pragma once #include <iomanip> #include <iostream> #include <string> struct Contestant { long id; // 学号 std::string name; // 姓名 std::string majo -
实验6 文件I/O与异常处理
实验任务1 实验代码: contestant.hpp: #pragma once #include <iomanip> #include <iostream> #include <string> struct Contestant { long id; std::string name; std:: -
实验6 文件I/O与异常处理
1. 实验任务1 contestant.hpp #pragma once #include <iomanip> #include <iostream> #include <string> struct Contestant { long id; // 学号 std::string name; // -
实验六
实验六 实验任务1 代码 contestant.hpp #pragma once #include <iomanip> #include <iostream> #include <string> struct Contestant { long id; // 学号 std::string name; -
区间选点问题 贪心算法的理解
问题 在数轴上给 n 个区间 [aᵢ, bᵢ],选最少的点,让每个区间至少包含一个点。 贪心策略 排序:按区间右端点从小到大排序 选点:从左到右扫描: 如果当前区间没被上一个点覆盖 就选这个区间的右端点作为新点 c++【 sort(区间, 按右端点排序); 点集合 = []; 上一个点 = -∞; -
实验06
任务1 代码 utils.hpp #pragma once #include <fstream> #include <iostream> #include <stdexcept> #include <string> #include <vector> #include "contestant.hpp -
实验6
1.实验任务1 此部分书写内容: 给出contestant.hpp, utils.hpp, task1.cpp源代码及运行结果截图(屏幕输出截图,及,生成数据文件ans.txt截图) contestant.hpp 点击查看代码 #pragma once #include <iomanip> #inc -
算法第五章作业
算法第五章作业 请用回溯法的方法分析“最小重量机器设计问题” 1.1 说明“最小重量机器设计问题”的解空间 “最小重量机器设计问题”是一个组合优化问题。每种部件可以从 m 个不同的供应商处购买,共有 n 个部件。 对于每个部件 i(i = 1, 2, ..., n),有 m 种选择(即从 m 个供应 -
实验六
task 1: // 运行程序输入测试时,可以把N改小一些输入测试 typedef struct student { int id; // 学号 char name[20]; // 姓名 char subject[20]; // 考试科目 double perf; // 平时成绩 double mi -
实验6
任务4 1 #include <stdio.h> 2 #include<string.h> 3 4 #define N 10 5 6 7 typedef struct { 8 char isbn[20]; // isbn号 9 char name[80]; // 书名 10 char author[ -
实验6
实验任务4 1 #include <stdio.h> 2 #define N 10 3 4 typedef struct { 5 char isbn[20]; // isbn号 6 char name[80]; // 书名 7 char author[80]; // 作者 8 double sale -
实验6
实验任务1 源代码 1 #define _CRT_SECURE_NO_WARNINGS 2 #include <stdio.h> 3 #include <string.h> 4 #define N 3 5 6 typedef struct student { 7 int id; 8 char nam -
实验6
实验1 #pragma once #include<iomanip> #include<iostream> #include<string> struct Contestant{ long id; std::string name; std::string major; int solved; in -
Section five Homework
当预算有限时,如何造出最轻的机器?——用回溯法解“最小重量机器设计问题” 在工程与算法的交汇处,我们常常要回答这样一个问题:如何在约束下做到“刚刚好”? 今天想和大家聊一个经典但容易被忽略的组合优化问题——最小重量机器设计问题。它不像旅行商那样广为人知,却真实反映了现实中的权衡艺术:在有限成本下,如 -
第五次作业
回溯算法是通过递归尝试所有可能的解路径,走不通就回退到上一步换路径的暴力枚举策略,核心是尝试-回退,还能通过剪枝减少无效计算。 它的关键特点: 1. 递归驱动:每一层递归对应一个决策选择(如选/不选物品)。 2. 状态回溯:尝试后恢复状态,保证其他路径不受影响。 3. 可选剪枝:提前排除无效路径,优 -
算法第五章作业
请用回溯法的方法分析“最小重量机器设计问题” 1.1 说明“最小重量机器设计问题"的解空间 有n个部件,每个部件可以从m个供应商处购买。则解空间有m的n次方个解 1.2 说明 “最小重量机器设计问题"的解空间树 解空间树的层数t为选择的部件t,每个节点有m个分支,代表选择第m个供应商。第n层节点表示