keshavfarmaha249
BAN USERint pole(int a[],int size)
{
int i,j;
int temp=a[0],c;
for(i=1;i<size;i++)
{
if(a[i]>=temp)
{ c=1;
temp=a[i];
for(j=i+1;j<size;j++)
{
if(a[j]<a[i])
c=0;
}
if(c)
return i;
}
}
return -1;
}
int pole(int a[],int size)
{
int i,j;
int temp=a[0],c=2;
for(i=1;i<size;i++)
{
if(a[i]>=temp)
{
temp=a[i];
for(j=i+1;j<size;j++)
{
if(a[j]<a[i])
c=0;
}
if(c)
return i;
}
}
return -1;
}
void rrot(int a[],int size,int n)
{
int i,j,temp;
n%=size;
for(i=0;i<n;i++)
{
temp=a[size-1];
for(j=size-1;j>0;j--)
{
a[j]=a[j-1];
}
a[j]=temp;
}
}
void print(char a[],int size)
{
int b,no,i,j,l;
l=size-2;
no=1;
while(l)
{
b=no;
j=0;
while(b)
{
for(i=0;i<=j;i++)
printf("%c ",a[i]);
printf("%d ",l);
for(i=l+j+1;i<size;i++)
printf("%c ",a[i]);
printf("\n");
b--;
j++;
}
no++;
l--;
}
}
int occur(int a[],int size,int t)
{
int count,lb=0,ub=size,mid,j;
count=0;
while(lb<=ub)
{
mid=(lb+ub)/2;
if(t==a[mid])
{
if(mid!=0)
{
j=mid-1;
while(t==a[j--])
count++;
}
while(t==a[mid++])
count++;
return count;
}
if(t>a[mid])
lb=mid+1;
if(t<a[mid])
ub=mid-1;
}
printf("Element Not Found\n");
exit(1);
}
- keshavfarmaha249 June 16, 2015