Beruflich Dokumente
Kultur Dokumente
}
else
{
last = middle - 1;
}
middle = (first + last)/2;
}
getch();
}
#include<stdlib.h>
#include<stdio.h>
i = 0;
j = 0;
k = l;
while (i < n1 && j < n2)
{
if (L[i] <= R[j])
{
arr[k] = L[i];
i++;
}
else
{
arr[k] = R[j];
j++;
}
k++;
}
}
}
merge(arr, l, m, r);
}
}
int main()
{
int arr[10],n,i;
clrscr();
printf("Enter the number of elements");
scanf("%d",&n);
printf("Enter the elements");
for (i=0;i<n;i++)
scanf("%d",&arr[i]);
printf("Given array is \n");
printArray(arr, n);
mergeSort(arr, 0, n - 1);
printf("\nSorted array is \n");
printArray(arr, n);
getch();
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int arr[10],n,i;
clrscr();
printf("Enter the number of elements");
scanf("%d",&n);
quickSort(arr, 0, n-1);
printf("Sorted array: n");
printArray(arr, n);
getch();
return 0;
}
# include<stdio.h>
if (i < n)
x[i] = u / weight[i];
tp = tp + (x[i] * profit[i]);
int main() {
float weight[20], profit[20], capacity;
int num, i, j;
float ratio[20], temp;
clrscr();
printf("\nEnter the no. of objects:- ");
scanf("%d", &num);
temp = weight[j];
weight[j] = weight[i];
weight[i] = temp;
temp = profit[j];
profit[j] = profit[i];
profit[i] = temp;
}
}
}
#include<conio.h>
#include<stdio.h>
for(k=1;k<=m;k++)
{
scanf("%d%d%d", &i,&j,&c);
cost[i][j]=c;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(cost[i][j]==0)
cost[i][j]=31999;
#include<iostream.h>
#include<conio.h>
Int cost [20][20];
int main ()
{
Int I,j,k, l=1,x=1,n1,n2[10], ans[10][10], path[10], path2[20];
Cout<<”Enter no. of stages : ”;
Cin>>n1;
n2[0]=1;
n2[n1-1]=1;
n2[n1]=0;
for(i=1;i<n-1;i++)
{
Cout<<”Options for stage”<<i+1<<”:”;
Cin>>n2[i];
}
for(i=1;i<n1;i++)
{
X=x+n2[i-1];
for(j=o;j<n2[i-1;j++])
{
for(k=0;k<n2[i];k++)
{
Cout<<”path”<<L<<”-->”<<x+k<<”:”;
Cin>>cost[i][j][k];
}
l++
}
}
X=l+1;
Path[m1]=l;
ans[n1][0];
for (i=n-1;i<0;i++)
{
x=x-n2[i];
for(j=0;j<n2[i-1];j++)
{
ans[i][j]=32767;
for(k=0;k<na[i];k++)
{
If(cost[i][j][k]+ans[i+1][k]<ans[i][j]&&cost[i][j][k]=32767)
{
path2[l-1]=x+k;
ans[i][j]=cost[i][j][k]+ans[i+1][k];
}
}
Cout<<path2[l-1]<<”,”<<x;
l--;
}
}
#include<stdio.h>
return K[n][W];
}
void main()
{
int i, n, val[20], wt[20], W;
clrscr();
printf("Enter number of items:");
scanf("%d", &n);