25.1 41. Array Menu C PDF
25.1 41. Array Menu C PDF
25.1 41. Array Menu C PDF
#include <stdio.h>
#include<stdlib.h>
struct Array
{
int *A;
int size;
int length;
};
}
}
int Delete(struct Array *arr,int index)
{
int x=0;
int i;
return 0;
}
while(l<=h)
{
mid=(l+h)/2;
if(key==arr.A[mid])
return mid;
else if(key<arr.A[mid])
h=mid-1;
else
l=mid+1;
}
return -1;
}
if(l<=h)
{
mid=(l+h)/2;
if(key==a[mid])
return mid;
else if(key<a[mid])
return RBinSearch(a,l,mid-1,key);
else
return RBinSearch(a,mid+1,h,key);
}
return -1;
}
return s;
}
B=(int *)malloc(arr->length*sizeof(int));
for(i=arr->length-1,j=0;i>=0;i--,j++)
B[j]=arr->A[i];
for(i=0;i<arr->length;i++)
arr->A[i]=B[i];
while(i<j)
{
while(arr->A[i]<0)i++;
while(arr->A[j]>=0)j--;
if(i<j)swap(&arr->A[i],&arr->A[j]);
}
return arr3;
}
arr3->length=k;
arr3->size=10;
return arr3;
}
arr3->length=k;
arr3->size=10;
return arr3;
}
arr3->length=k;
arr3->size=10;
return arr3;
}
int main()
{
struct Array arr1;
int ch;
int x,index;
switch(ch)
{
case 1: printf("Enter an element and index
");
scanf("%d%d",&x,&index);
Insert(&arr1,index,x);
break;
case 2: printf("Enter index ");
scanf("%d",&index);
x=Delete(&arr1,index);
printf("Deleted Element is %d\n",x);
break;
case 3:printf("Enter element to search ");
scanf("%d",&x);
index=LinearSearch(&arr1,x);
printf("Element index %d",index);
break;
case 4:printf("Sum is %d\n",Sum(arr1));
break;
case 5:Display(arr1);
}
}while(ch<6);
return 0;
}