图一
第二个写法有问题
应改为:
int Search(int aar[], int n, int x){ int i,j; for (i = 0; i < n; i++) if (arr[i] == x) { j = i; return j; } return -1; }
对比下,看能发现问题不