Moderator: Board moderators
mystical_liu wrote:i fix my code but it still WA!!
can you say more clear???
i find the smallest number and change
Is there any thing i didn't consider???
[cpp]
#include<stdio.h>
int in[5000],input,time=0,ins,min=0;
main()
{
int i,j;
while(scanf(" %d",&input)==1)
{
time=0;
for(i=0;i<input;i++)
scanf(" %d",&in[i]);
for(i=0;i<input;i++)
{
min=i;
for(j=i+1;j<input;j++)
if(in[i]>in[j]) <-------- in[min]>in[j] i think is what you want
min=j;
if(in[i]>in[min])
{
ins=in[i];
in[i]=in[min];
in[min]=ins;
time++;
}
}
printf("Minimum exchange operations : %d\n",time);
}
}[/cpp]
Users browsing this forum: No registered users and 1 guest