Here is the question : http://www.sendspace.com/file/qu6bpi
I upload the code to my school checking system,
and it said that I can only pass 6 hidden cases out of 10.
I don't know where the problem is. :'(
Here is my code : (can only use looping,if,array,pointer)
#include<stdio.h>
#include<math.h>
#define N 200
#define B 100
void swap(int *p,int *q,int swap1,int swap2)
{
int temp;
temp=p[swap1];
p[swap1]=q[swap2];
q[swap2]=temp;
return;
}
void main()
{
int n,i,j,min=60,k,s,m;
int a[N]={},b[B]={};
int *p=NULL,*q=NULL;
double t;
scanf("%d",&n);
t=floor(1.2*n);
for (i=0;i<t;i++)
{
scanf("%d",&a[i]);
if (a[i]>80 || a[i]<6)
goto end;
for (k=0;k<n;k++)
{
if (a[k]>10 && a[k]<60)
{
m=1;
break;
}
}
switch(m)
{
case 1:
{
if (i>=n && (a[i]<11 || a[i]>59))
{
for (k=0;k<n;k++)
{
if (a[k]>10 && a[k]<60)
{
if (a[k]<min)
{
min=a[k];
s=k;
b[i]=s;
}
}
}
swap(a,a,s,i);
min=60;
for(k=s+1;k<n;s++,k++)
swap(a,a,s,k);
}
else b[i]=i;
break;
}
default: b[i]=i;break;
}
for (j=n;j<=i;j++)
{
for (k=j+1;k<=i;k++)
{
if (b[j]>b[k])
{
swap(a,a,j,k);
swap(b,b,j,k);
}
}
}
printf("\nsitting ");
for (j=0;j<=i && j<n;j++)
printf("%d ",a[j]);
printf("\n\n");
if (i>=n)
{
printf("standing ");
for (j=n;j<=i && j<t;j++)
printf("%d ",a[j]);
printf("\n\n");
}
}
if (i==t)
printf("\n\nbus full\n\n");
end:;
}
Thanks:'(