Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
选择排序超时啊~~~~~~~·#include <stdio.h> #include <stdlib.h> int sort(int a[],int n) { int i,j,k,t,flag; flag=0; for (i=0;i<n-1;i++) { k=i; for (j=i+1;j<n;j++) { if (a[j]<a[k]) { k=j; } } if (a[k]!=a[i]) { flag++; } t=a[k]; a[k]=a[i]; a[i]=t; } return (flag); } int main() { int a,i,n; int m[10000]; scanf("%d",&a); while (a--) { scanf("%d",&n); for (i=0;i<n;i++) { scanf("%d",&m[i]); } printf("%d\n",sort(m,n)); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator