#include<stdio.h>
#define SIZE 5
int main()
{
int a[SIZE];
int i,j;
int count=0;
printf("\nEnter the numbers in the array:\n");
for(i=0;i<SIZE;i++)
{
scanf("%d",&a[i]);
printf("\na[%d] = %d ",i,a[i]);
}
for(i=0;i<SIZE;i++)
{
for(j=i+1;j<SIZE;j++)
{
if(a[i]>a[j])
count++;
printf("\n Count increment in progress....Current
Count=%d",count);
}
}
printf("\nThe Value of count is:%d",count);
return 0;
}
Regards,
Ashish
On Sun, Jun 27, 2010 at 9:59 AM, sharad kumar <[email protected]>wrote:
> Give an unsorted array find count of pairs of numbers[a,b] where a > b and
> b comes after a in the array.
>
> Eg. {8,3,6,10,5}
>
> the count of such numbers is 5. i.e. (8,3), (8,6), (8,5), (6,5) and (10,5)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.