Posted in 面试题 onNovember 14, 2012
解: main()
{ int i,n;
char *p,num[20];
printf(“input n:”);
scanf(“%d”,&n);
printf(“Please input these number:\n”);
for(i=0,i
scanf(“%d”,&num[i]);
p=&num[0];
sort(p,n);
printf(“Now, the sequence is:\n”);
for(i=0;i
printf(“%d ”,num[i]);
}
sort(char p,int m)
{int i;
char temp,*p1,*p2;
for(i=0;i
{p1=p+i;
p2=p1+(m-1-i);
temp=*p1;
*p1=*p2;
*p2=temp;
}
}
{ int i,n;
char *p,num[20];
printf(“input n:”);
scanf(“%d”,&n);
printf(“Please input these number:\n”);
for(i=0,i
p=&num[0];
sort(p,n);
printf(“Now, the sequence is:\n”);
for(i=0;i
}
sort(char p,int m)
{int i;
char temp,*p1,*p2;
for(i=0;i
p2=p1+(m-1-i);
temp=*p1;
*p1=*p2;
*p2=temp;
}
}
将n个数按输入顺序的逆序排列,用函数实现
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Tags in this post...
Reply on: @reply_date@
@reply_contents@