首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
当先后输入1、3、4、12、23时,屏幕上出现【 】;再输入12时,则屏幕上出现【 】。 #include <stdio.h> #define N 5 main() { int i,j,number,top,bott,min,loca,a[
当先后输入1、3、4、12、23时,屏幕上出现【 】;再输入12时,则屏幕上出现【 】。 #include <stdio.h> #define N 5 main() { int i,j,number,top,bott,min,loca,a[
admin
2009-02-15
23
问题
当先后输入1、3、4、12、23时,屏幕上出现【 】;再输入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
>a[i-1])\n");
scanf("%d",&a[0]);
i=1;
while (i<N)
{ scanf("%d",&a
);
if (a
>=a[i-1)) i++;
}
printf("\n");
for (i=0;i<N;i++) printf("%d",a
);
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;
}
}
选项
答案
1 3 4 12 23 12 is the 4th number.
解析
转载请注明原文地址:https://kaotiyun.com/show/c8Xp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
线性表的链式存储结构与顺序存储结构相比,链式存储结构的优点有()。
阅读程序:OptionBase1PrivateSubForm_Click()DimArr(3,3)AsIntegerFori=1To3ForJ=1To3Ifj=iOrj=3-
编写如下程序:PrivateSubCommand1_Click()DimxAsIntegerx=10Printfun1(x,12)+xEndSubPrivateFunctionf
以下叙述中错误的是()。
编写如下程序:PrivateSubCommandl_Click()DimaAsInteger,bAsIntegera=3b=2Ifa*b<10Thenb=b+1Elseb=b-1
语句PriatFormat$(23846.5,"000,000.00")的输出结果是()。
设有课程关系模式如下:R(C#,Cn,T,Ta)(其中c}}为课程号,cn为课程名,T为教师名,Ta为教师地址)并且假定不同课程号可以有相同的课程名,每个课程号下只有一位任课教师,但每位教师可以有多门课程。该关系模式可进一步规范化为()。
下列关于控件数组的叙述中,正确的是()。
语句Dima(-3To4,3To6)AsInteger定义的数组的元素个数是
以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:abc123edf456gh,执行程序后输出:123456。请填空。#include#includemain(){chars[80],d[80];
随机试题
大小不变或变化缓慢的载荷称为()。
染色体畸变可由亲代遗传,也可由生殖细胞的异常发育引起,包括_______的异常和_______的改变。
X企业为一般增值税纳税人,购入一台设备,该设备需安装,取得增值税专用发票注明买价为140万元,增值税税额为23.8万元,支付的运费为0.5万元,支付安装费为0.3万元,则固定资产入账价值为164.6万元。()
2012年度中国公民赵某取得以下所得:(1)利用业余时间兼职,1~12月份每月从兼职单位取得劳务报酬3000元每月从中拿出500元通过国家机关捐赠给贫困地区。(2)通过拍卖行将一幅珍藏多年的字画拍卖,取得收入500000元,该字画原值
长江三角洲的地理位置十分优越,体现在()。①濒临黄、渤海与长江交汇处,港口众多②依托长江水运,联系内陆地区③我国南北海上航运中枢④通过远洋航线通往世界主要港口
【2014下】马克思主义认为,实现人的全面发展的根本途径是()。
能够引起债的绝对消灭的原因有()。
A、Studyingwithapartner.B、Preparingsnacks.C、Playingcards.D、Learninghowtodesignbridges.C女士说:“我打算去学生娱乐中心打桥牌。”故答案为C。
ScientistsatSussexuniversityappeartobeonthewaytodiscoveringhowthemosquito,earnerofdiseasessuchasmalariaand
A、Thesmallbowlwasputabovethelargebowl.B、Thelargebowlwasputabovethesmallbowl.C、Thesmallbowlwasputinsideth
最新回复
(
0
)