Page 6 of 6
Re: 10327 - Flip Sort
Posted: Tue Jun 18, 2013 1:19 am
by brianfry713
Your code never terminates.
10327 - Flip Sort
Posted: Sat Dec 07, 2013 7:51 pm
by habib_ruet_cse_12
I think the problem has some difficulties. Why i can,t change the values between each other. why i can't swap. with out swapping i can't sort my values... Admin please clear me...
Re: 10327 - Flip Sort
Posted: Tue Dec 10, 2013 12:51 am
by brianfry713
Re: 10327 - Flip Sort
Posted: Sat Oct 11, 2014 6:33 pm
by xrenon
DELETED
Re: 10327 - Flip Sort
Posted: Sun Oct 12, 2014 1:15 pm
by lighted
In this approach only one operation ( Flip ) is available and that is you can exchange two adjacent terms.
According to problem description you can exchange only two
adjacent terms.
Re: 10327 - Flip Sort
Posted: Fri May 01, 2015 9:27 pm
by quanghm
I would like to argue that the problem is ill-posed. At least, there's a conflict between the text (a number N followed by several lines) while the sample input showed two data sets with two "different" N as one can see in the sample output.
The reference program at udebug seemed to agreed with the problem text, but seems to ignore the number N and process each line individually. For example
3
1 2 3
3 2 1
4
1 2 3 4
4 2 3 1
would give 5 lines and treats the last 3 lines as permutation on 4 letters, not 3.
Re: 10327 - Flip Sort
Posted: Sat May 23, 2015 7:46 pm
by fayed22
why my code is getting is runtime error...plz help..
Code: Select all
#include<stdio.h>
int main()
{
int i,p[100],n,b,j,count;
while((scanf("%d",&n))==1&&n!='\0')
{
count=0;
for(i=0;i<n;i++)
{
scanf("%d",&p[i]);
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
if(p[j]>p[j+1])
{
b=p[j];
p[j]=p[j+1];
p[j+1]=b;
count++;
}
}
printf("Minimum exchange operations : %d\n",count);
}
return 0;
}