#include<stdio.h>
int main()
{
int i, j, temp, n, k = 0;
printf("Enter Any Number : ");
scanf("%d",&n);
int anik[n];
for(i=0; i<n; i++)
{
scanf("%d",&anik[i]);
}
for(i=0; i<n; i++)
{
for(j=i+1; j<n; j++)
{
if(anik[i]<anik[j])
{
k++;
temp = anik[i];
anik[i] = anik[j];
anik[j] = temp;
}
}
}
printf("Descending is : ");
for(i=0; i<n; i++)
{
printf("%d ",anik[i]);
}
printf("\nExchange Operation : %d\n", k);
return 0;
}
int main()
{
int i, j, temp, n, k = 0;
printf("Enter Any Number : ");
scanf("%d",&n);
int anik[n];
for(i=0; i<n; i++)
{
scanf("%d",&anik[i]);
}
for(i=0; i<n; i++)
{
for(j=i+1; j<n; j++)
{
if(anik[i]<anik[j])
{
k++;
temp = anik[i];
anik[i] = anik[j];
anik[j] = temp;
}
}
}
printf("Descending is : ");
for(i=0; i<n; i++)
{
printf("%d ",anik[i]);
}
printf("\nExchange Operation : %d\n", k);
return 0;
}
Comments
Post a Comment