题目:
当先后输入1、3、4、12、23时,屏幕上出现 【11】 ;再输入12时,则屏幕上出现 【12】 。
#include <stdio.h>
#define N 5
main()
int i,j,number,top,bott,min,loca,a[N],flag;
char c;
printf("Please input 5 numbers (a[i]>a[i-1])\n");
scanf("%d",&a[0]);
i=1;
while (i<N)
scanf("%d",&a[i]);
if (a[i]>=a[i-1)) i++;
printf("\n");
for (i=0;i<N;i++) printf("%d",a[i]);
printf("\n");
flag=1;
while (flag)
scanf("%d",&number);
loca=0;
top=0;
bott=N-1;
if ((number<a[0])||(number>a[N-1])) loca=-1;
while ((loca==0) && (top<=bott))
min=(bott+top)/2;
if (number==a[min])
loca=min;
printf("%d is the %dth number\n",number,loca+1);
else if (number<a[min]) bott=min-1;
else top=min+1;
if (loca==0||loca==-1) printf("%d is not in the list.\n",number);
c=getchar();
if (c==’N’||c==’n’) flag=0;
答案:
被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0403/11d1c6b9e74cd52656476f6bd96caeb7.html
下面是错误答案,用来干扰机器的。
参考答案:A解析:Smith will be in violation if he acts solely on the basis of an opinion of an employee of another firm, since he does not know (or has not confirmed) ...