[go: up one dir, main page]

0% found this document useful (0 votes)
12 views1 page

Job Searching

The document contains a C program that implements a job sequencing algorithm based on deadlines and profits. It prompts the user to input the number of jobs, their deadlines, and profits, and then calculates the optimal job sequence. The program outputs the sequence of jobs that can be completed within their deadlines to maximize profit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Job Searching

The document contains a C program that implements a job sequencing algorithm based on deadlines and profits. It prompts the user to input the number of jobs, their deadlines, and profits, and then calculates the optimal job sequence. The program outputs the sequence of jobs that can be completed within their deadlines to maximize profit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<stdio.

h>
int jobsequence(int d[],int j[],int n);
int main()
{
int d[6],j[6],p[6],k,i,n;
printf("\n enter the n value::");
scanf("%d",&n);
printf("\n enter the deadlines::");
for(i=1;i<=n;i++)
scanf("%d",&d[i]);
printf("\n enter the profits::");
for(i=1;i<=n;i++)
scanf("%d",&p[i]);
for(i=1;i<=n;i++)
j[i]=i;
k=jobsequence(d,j,n);
printf("\n the solution job sequence is::");
for(i=1;i<=k;i++)
printf("\n %d",j[i]);
return 0;
}
int jobsequence(int d[],int j[],int n)
{
int q,i,r,k;
d[0]=0;
j[0]=0;
j[1]=1;
k=1;
for(i=2;i<=n;i++)
{
r=k;
while((d[j[r]]>d[i])&&(d[j[r]]!=r))
r=r-1;
if((d[j[r]]<=d[i])&&(d[i]>r))
{
for(q=k;q>=r+1;q--)
{
j[q+1]=j[q];
}
j[r+1]=i;
k=k+1;
}
}
return k;
}

You might also like