当前位置: 首页 > news >正文

4成都网站建设大数据营销案例

4成都网站建设,大数据营销案例,聊城九洲建设有限公司网站,网站建设几大类型1.暴力递归 &#xff08;1&#xff09;剩余金额小于0&#xff0c;无解 剩余金额等于0&#xff0c;有解 剩余金额大于0&#xff0c;继续递归 &#xff08;2&#xff09;从大的硬币到小的硬币&#xff0c;可以减少循环次数 #include <bits/stdc.h> using namespace std;…

 1.暴力递归

(1)剩余金额小于0,无解

        剩余金额等于0,有解

        剩余金额大于0,继续递归

(2)从大的硬币到小的硬币,可以减少循环次数

#include <bits/stdc++.h>
using namespace std;int amount;
int coins[10]={5,2,1};
int res(int index,int* coins,int remainder)
{
//    剩余金额小于0,无解if(remainder<0){return 0;}
//    剩余金额等于0,有解else if(remainder==0){return 1;}
//    剩余金额大于0,继续递归else{int mycount=0;for(int i=index; i<3; i++){mycount+=res(i,coins,remainder-coins[i]);}return mycount;}}int main()
{amount=5;cout<<res(0,coins,amount);
}

如果要输出方案的话要用栈,让gpt写一下

#include <iostream>
#include <stack>
using namespace std;int amount;
int coins[10] = {1, 2, 5};void printCombination(stack<int>& combination) {stack<int> tempStack;while (!combination.empty()) {tempStack.push(combination.top());combination.pop();}cout << "Combination: ";while (!tempStack.empty()) {cout << tempStack.top() << " ";combination.push(tempStack.top());tempStack.pop();}cout << endl;
}int res(int index, int* coinList, int remainder, stack<int>& combination) {if (remainder < 0) {return 0;} else if (remainder == 0) {printCombination(combination);return 1;} else {int mycount = 0;for (int i = index; i < 3; i++) {combination.push(coins[i]);mycount += res(i, coinList, remainder - coins[i], combination);combination.pop();}return mycount;}
}int main() {amount = 5;stack<int> combination;cout << "Total combinations: " << res(0, coins, amount, combination) << endl;return 0;
}

http://www.yayakq.cn/news/591855/

相关文章:

  • 深圳宝安龙岗紧急寻人网站导航优化
  • 设计网站公司的账务处理小程序注册后怎么使用
  • 上门做网站哪里有网店运营
  • 生物做实验的网站discuz 网站标题
  • 什么是网站设计种类wordpress固定链接显示404
  • 关于旅游网站策划书大企业网站建设费用
  • 茌平做网站视频拍摄收费标准
  • 网站怎么做百科外贸网站推广策划
  • 房地产网站怎样建设才能快速盈利网站备案被拒
  • 网站开发中安全性医院网站建设报价表
  • 易语言如何做网站登录网站建设对旅游意义
  • 贸易公司寮步网站建设哪家好网站页面头部设计说明
  • 手机app开发网站新手建设html5网站
  • 网站标题切换如何学习wordpress
  • 网站开发加盟商怎么做郑州区块链数字钱包网站开发多少钱
  • django怎么做网站江门网站排名优化
  • 湖北商城网站建设多少钱网站素材大全
  • 查询网站whois外链代发免费
  • app购物网站建设秦皇岛短视频优化
  • 宁夏自治区建设厅官方网站做跨境电商网站有哪些
  • php做网站要多久吴江做网站
  • 怎么制作网站游戏网站建设推广价格
  • 福州百度分公司网站做seo需要大量文章
  • 运动鞋网站建设目的wordpress插件外链
  • 重庆网站建设网页设计wordpress分享小图片不
  • 莆田建设企业网站百度推广管家登录
  • 公司网站 cmswordpress single.php
  • wordpress购物网站上海招聘网站排名
  • 深圳网站建设怎样快速亚马逊代运营
  • 潍坊seo建站网站建设 博采