Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72268
  • 博文数量: 20
  • 博客积分: 1213
  • 博客等级: 中尉
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-21 23:22
个人简介

C++1111111111111111111111111111111222222222222222222222222222222

文章分类
文章存档

2016年(1)

2011年(1)

2009年(18)

最近访客

分类: C/C++

2009-11-24 14:48:28

#include
int main(int argc, char **argv)
{
 int i,j,len,min,time=0;
 int s[]={3,8,2,-1,4,6,5};
 len=sizeof(s)/sizeof(s[0]);
 for(i=0;i {
  min=i;
  for(j=i+1;j  {
   if(s[j]   {
    min=j;
   }
  }
  if(i!=min)
  {
   time++;
   s[i]=s[i]+s[min];
   s[min]=s[i]-s[min];
   s[i]=s[i]-s[min];
  }
 }
 printf("time = %d\n",time);
 for(i=0;i {
  printf("%d ",s[i]);
 }
 printf("\n");
 return 0;
}
阅读(1381) | 评论(1) | 转发(0) |
0

上一篇:一年的第几天

下一篇:串中有几个单词

给主人留下些什么吧!~~

fera2009-12-04 17:49:30

Selection Sort: int FindPos(int* aArray, int aCurPos, int aLen) { int pos = aCurPos; int key = aArray[aCurPos]; // Start from current position which is the begin of unsorted array. for (int i = aCurPos; i < aLen; ++i) { if (aArray[i] < key) { // Update the position found and the smallest element. pos = i; key = aArray[i]; } } return pos; } void SelectionSort(int* aArray, int aLen) { //