-
实验五
任务一 1.c 点击查看代码 #include <stdio.h> #define N 5 void input(int x[], int n); void output(int x[], int n); void find_min_max(int x[], int n, int* pmin, in -
选点问题的贪心解法
最近在算法课上学到了贪心算法,老师布置了这个“选点问题”。题目要求在数轴上选最少的点,使得每个给定区间都至少包含一个点。 我一开始试着画了几个例子。比如给三个区间:[1,3]、[2,4]、[3,5]。如果随便选点,可能在1、2、3各放一个点,用了三个点。但仔细观察,其实选点3就能覆盖所有区间。这让我 -
实验5
实验任务1 1.函数find-min-max的功能是找到一维数组中的最大值和最小值 2.分别指向主函数中定义的变量min和max的内存地址 1.找到数组x中最大值所在的下标同时返回其对应的数组元素 2.不可以。理由ptr是int*类型而x[i]是int类型,不能将x[i]赋值给ptr 实验任务2 1 -
5
#include <stdio.h> #define N 5 void input(int x[], int n); void output(int x[], int n); void find_min_max(int x[], int n, int *pmin, int *pmax); int m -
实验5
任务1: 源代码: publisher.hpp #pragma once #include <string> // 发行/出版物类:Publisher (抽象类) class Publisher { public: Publisher(const std::string &name_ = ""); -
实验5
task1_1 #include <stdio.h> #define N 5 void input(int x[], int n); void output(int x[], int n); void find_min_max(int x[], int n, int* pmin, int* pmax -
实验五
#include <stdio.h> #define N 5 void input(int x[], int n); void output(int x[], int n); void find_min_max(int x[], int n, int *pmin, int *pmax); int m -
sy5
task 1 找到最大值和最小值 x【0】所在的地址。 可以 task2 s1大小:80 sizeof(s1)计算的是数组s1所占的字节数 strlen(s1)统计的是数组s1所含有元素的数量 不能,数组名为指向数组首元素的常量指针,不能为其赋值 交换 task3 s1存放的是该数组首元素的地址 s -
实验五
实 验 1 1 #include <stdio.h> 2 #define N 5 3 4 void input(int x[], int n); 5 void output(int x[], int n); 6 void find_min_max(int x[], int n, int *pmin, -
实验五
task.1.1 点击查看代码 #include<stdio.h> #define N 5 void input(int x[],int n); void output(int x[],int n); void find_min_max(int x[],int n,int *pmin,int *pm -
实验五
`#include <stdio.h> define N 5 void input(int x[], int n); void output(int x[], int n); void find_min_max(int x[], int n, int *pmin, int *pmax); int m -
高级语言程序设计课程第九次个人作业
这个作业属于哪个课程:https://edu.cnblogs.com/campus/fzu/gjyycx 这个作业要求在哪里: https://edu.cnblogs.com/campus/fzu/gjyycx/homework/15595 学号:<052301346> 姓名:<郑积超> 作业内容 -
实验5
1.实验任务1 #include <stdio.h> #define N 5 void input(int x[], int n); void output(int x[], int n); void find_min_max(int x[], int n, int *pmin, int *pmax -
实验5
task 1-1 点击查看代码 #include <stdio.h> #define N 5 void input(int x[], int n); void output(int x[], int n); void find_min_max(int x[], int n, int *pmin, i -
实验五
任务一 1.筛选所录入数据的最大值和最小值。 2.pmin指向min,pmax指向max 3.筛选所录入数据的最大值 4.可以 任务二 1.80,sizeof指针大小,strlen有效字符个数 2.不能,缺少s2程序无法运行 3.是 4.存储的是字符串常量"Learning makes me hap -
实验5
试验任务1 源代码 publisher.hpp 点击查看代码 #pragma once #include <string> // 发行/出版物类:Publisher (抽象类) class Publisher { public: Publisher(const std::string &name_ -
实验五
实验任务一 代码 publisher.hpp 点击查看代码 #pragma once #include <string> // 发行/出版物类:Publisher (抽象类) class Publisher { public: Publisher(const std::string &name_ = -
高级语言程序设计课程第九次个人作业
这个作业属于哪个课程:https://edu.cnblogs.com/campus/fzu/gjyycx 这个作业要求在哪里:https://edu.cnblogs.com/campus/fzu/gjyycx/homework/15595 学号:102500334 姓名:吴俊杰 1.声明一个结构体类 -
高级语言程序设计课程第九次个人作业
这个作业属于哪个课程:https://edu.cnblogs.com/campus/fzu/gjyycx 这个作业要求在哪里: https://edu.cnblogs.com/campus/fzu/gjyycx/homework/15595 学号:102500305 姓名:赖晓娟 一.声明一个结构体 -
第四章作业
一、选点问题分析(经典区间选点问题) 问题定义 给定若干个闭区间 [a_i, b_i],要求选择最少数量的点,使得每个区间至少包含一个选点。 贪心策略 核心策略:按区间的右端点从小到大排序,依次遍历每个区间;若当前区间未被已选点覆盖,则选择该区间的右端点作为新的选点。 具体步骤: 将所有区间按右端点