C++ 有用的书籍

C++ 有用的书籍
Essential C++ 中文版
C++ Primer Plus 第6版中文版
C++ Primer中文版(第5版)

 1 #include <iostream>
 2 
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 int main(int argc, char** argv) {
 6     void select_sort(int *p,int n);
 7     int a[10],i;
 8     cout<<"enter the originl array:"<<endl;
 9     for(i=0;i<10;i++)
10     cin>>a[i];
11     cout<<endl;
12     
13     select_sort(a,10);
14     cout<<"the sorted array:"<<endl;
15     for(i=0;i<10;i++)
16     cout<<a[i]<<" ";
17     cout <<endl;
18     return 0;
19 }
20 
21 void select_sort(int *p,int n)
22 {
23     int i,j,k,t;
24     for(i=0;i<n-1;i++)
25     {
26         k=i;
27         for(j=i+1;j<n;j++)
28         if(*(p+j)<*(p+k))k=j;
29         t=*(p+k);
30         *(p+k)=*(p+i);
31         *(p+i)=t;
32     }
33 }
原文地址:https://www.cnblogs.com/borter/p/9401406.html