皮皮学,免费搜题
登录
logo - 刷刷题
搜题
【简答题】
阅读以下说明和C程序,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 假设需要将N个任务分配给N个工人同时去完成,每个人承担这N个任务, 但费用不同。下面的程序用回溯法计算总费用最小的一种工作分配方案,在该方案中,为每个人分配1个不同的任务。 ,N个任务从0开始依次编号,N个工人也从0开始依次编号,主要的变量说明如下: c[i][j]:将任务i分配给工人j的费用; task[i]:值为0表示任务i未分配,值为j表示任务i分配给工人j; worker[k]:值为0表示工人k未分配任务,值为1表示工人k已分配任务; mincost:最费用。 【C程序】 #include<stdio.h> #define N 8 /*N表示任务数和工人数*/ int c[N][N]; unsigned int mincost=65535; /*设置min的初始值,大于可能的总费用*/ int task[N],temp[N],workerIN]; void Plan(int k,unsigned Int cost) { int i; if ((1)&&cost<mincost){ mincost=cost; for (i=0;i<N;i++) temp[i]:task[i]; } else{ for(i=0;i<N;i++) /*分配任务k*/ if (worker[i]=0&&(2)){ worker[i]=1; task[k]=(3); Plan((4),cost+c[k][i]); (5); task[k]=0; }/*if*/ } }/*Plan*/ void main() {int i,j; for (i=0;i<N;i++) { /*设置每个任务由不同工人承担时的费用及全局数组的初值*/ worker[i]=0;task[i]=0; temp[i]=0; for(j=0;j<N;j++) scanf ('%d',&c[i][j]); } Plan (0,0); /*从任务0开始分配*/ printf('/n最小费用=%d/n',mincost); for(i二0;i<N;i++) pnntf('Task%d iB assigned toWorker%d/n',i,temp[i]); }/*main*/
手机使用
分享
复制链接
新浪微博
分享QQ
微信扫一扫
微信内点击右上角“…”即可分享
反馈
参考答案:
举一反三
【单选题】Rock climbing is so popular now that many people are able to ______ the steepest face with great agility.
A.
scale
B.
surpass
C.
overcome
D.
mount
【简答题】The Bear Valley Adventure Camp is a high-energy experience focusing on safe outdoor climbing and an appreciation for the natural environment. Along the way campers can also swim, hike, and canoe ...
【单选题】So violently ______ to be mad that for a moment or two the Princess was unable even to whisper in her ear.
A.
did she pretend
B.
she pretended
C.
pretended she
D.
had she pretended
【简答题】阅读理解。 Peter was mad on mountains. Climbing was the love of his life. Church towers, seaside cliffs, rock faces, ice mountains, anything-'If it's there,' he used to say, 'then I want to climb it.' So t...
【单选题】Peter Fern was mad on mountains. Climbing was the love of his life. Church towers, seaside cliffs, rock faces, ice mountains, anything—'if it's there' he used to say, 'then I want to climb it'. So the...
A.
he enjoyed to climb mountains
B.
he was angry on mountains
C.
he lost his senses on mountains
D.
he enjoyed climbing mountains very much
【单选题】哪个运动不存在奇异点 ?
A.
LIN
B.
CIRC
C.
SPL
D.
PTP
【判断题】选区激光熔化成型工艺所用激光功率密度小于选区激光烧结融化成型工艺。
A.
正确
B.
错误
【简答题】选区激光熔化成型工艺所用激光功率密度 选区激光烧结融化成型工艺。
【单选题】While he was climbing the high mountain, he had his leg ______.
A.
broke
B.
break
C.
broken
D.
breaking
【单选题】I can't understand _______ Apple's iPad 2. [     ]
A.
why are they so mad about
B.
why they are so mad about
C.
how are they so mad about
D.
 how they are so mad about
相关题目:
参考解析:
知识点:
题目纠错 0
发布
创建自己的小题库 - 刷刷题