一.现象及原因
现象:在一个工程中有2个带有main函数的文件:InsertSort.cpp,ShellSort.cpp
InsertSort.cpp
1 #include <stdio.h> 2 3 void InsertSort(int A[],int n) 4 { 5 int i,j; 6 for(i=2;i<=n;i++) 7 { 8 if(A[i]<A[i-1]) 9 { 10 A[0]=A[i]; 11 for(j=i-1;A[0]<A[j];--j) 12 { 13 A[j+1]=A[j]; 14 15 } 16 17 A[j+1]=A[0]; 18 } 19 } 20 } 21 22 void InsertSort_1(int A[],int n) 23 { 24 int i,j,temp; 25 for(i=1;i<n;i++) 26 { 27 if(A[i]<A[i-1]) 28 { 29 temp=A[i]; 30 for(j=i-1;A[j]>temp;j--) 31 { 32 A[j+1]=A[j]; 33 34 } 35 36 A[j+1]=temp; 37