摘要:
#include<iostream>#include<algorithm>#include<ctime>#include<cstdlib>using namespace std;void maxHeap(int *a,int n,int i){ int left=i<<1,right=i<<1|1; if(left > n) return; int large=left; if(right <= n && a[right] > a[large]) large=right; if(a[i] 阅读全文
摘要:
View Code #include<stdio.h>int fn(int * a,int n,int x){ int s=0,e=n-1; int mid; while(s<=e) { mid=(s+e)>>1; if(a[mid] == x) return mid; else if(a[mid] > x) e=mid-1; else s=mid+1; } return -1;}int main(){ int i,a[10]; for(i=0;i<10;i++) { a... 阅读全文