• 2021-04-14
    折半查找,完善以下程序:
    #include
    main()
    {
    int a[10]={1,3,5,7,9,11,13,15,17,19},k,low,high,mid,cnt;
    low=0;high=9;cnt=0;
    printf("请输入要查找的数:");
    scanf("%d",&k);
    while( 空1 )
    {
    cnt++;
    mid=(low+high)/2;
    if(k == a[mid])
    break;
    else if(k > a[mid])
    空2


    空3
    }
  • 举一反三