c++ - 如何为迭代函数编写递归关系
问题描述
目前我正在做一个项目,我必须提供一个函数的递归关系。问题是该函数是一个迭代函数,我没有设法写出它的递归关系。另外,我不确定这样的事情是否可能。有没有办法为迭代函数编写递归关系。
这是我挣扎的代码:
typedef Pair<Job*>* Schecule;
vector<Schecule>* scheculeJobs(Job* jobs[],int jobCount){
mergeSort(jobs,0,jobCount - 1 ); // O(nlogn)
vector<Schecule>* schedules = new vector<Schecule>();
for (int i = 0; i < jobCount; i++){
Job* firstJob = jobs[i];
for(int j = i +1 ; j < jobCount ; j++){
Job* secondJob = jobs[j];
Schecule schedule = new Pair<Job*>(firstJob,secondJob);
schedules->push_back(schedule);
if(schedule->first->deadline == schedule->second->deadline){
Schecule inverseSchedule = new Pair<Job*>
(secondJob,firstJob);
schedules->push_back(inverseSchedule);
}
}
}
return schedules;
}
解决方案
推荐阅读
- r - 在图形上显示方程 (ggplot2)
- python - 如何使 Tkinter Button 更改其自己的文本属性?
- arrays - 如何在程序中搜索 Java 中的最高/最低值?
- javascript - 如何在 python 中将 JavaScript 解析为 JSON?
- r - 在 Azure ML 虚拟机中加载 rds 文件时的不同结果
- function - 如何记录 keras 损失函数
- angular - 从 Angular 8 组件获取打开窗口的 url 更改
- python - Pylint:方法可能是基类中的函数
- azure - 通过工作流自动化和 Azure 安全中心警报触发逻辑应用
- bash - Bash - 增加一个变量,直到它可以在另一个变量中找到 + 如果它匹配一个条件