[说明]
对于具有n个元素的整型数组a,需要进行的处理是删除a中所有的值为0的数组元素,并将a中所有的非0元素按照原顺序连续地存储在数组空间的前端。下面分别用函数CompactArr_v1和CompactArr_v2来实现上述处理要求,函数的返回值为非零元素的个数。
函数CompactArr_v1(int a[],intn)的处理思路是:先申请一个与数组a的大小相同的动态数组空间,然后顺序扫描数组a的每一个元素,将遇到的非0元素依次复制到动态数组空间中,最后再将动态数组中的元素传回数组a中。
函数CompactArr_v2(int a[],int n)的处理思路是:利用下标i(初值为0)顺序扫描数组a的每一个元素,下标k(初值为0)表示数组a中连续存储的非0元素的下标。扫描时,每遇到一个数组元素,i就增1,而遇到非0元素并将其前移后k才增1。
[C函数1]
int CompactArr_v1(int a[],int n)
int i,k;
int*temp=(int*)malloc(n* (1)
if(!temp)
return-1;
for(i=0,k=0;i<n;i++)
if(a[i]!=0)
(2) =a[i];
for(i=0; (3) ;i++)
a[i]=temp[i];
return k;
[C函数2]
int CompactArr v2(int a[],int n)
int i,k;
for(i=0,k=0;i<n;i++)
if(a[i]!=0)
(4) =a[i];
return k;
请根据说明中函数CompactArr_v1的处理思路填补空缺(1)~(3),根据CompactArr_v2的处理思路填补空缺(4)。
On Tuesday August 11th, 1911, a young
artist, Louis Beraud, arrived at the Louvre in Paris to complete a painting of
the Salon Carre. This was the room where the world’s most famous painting, the
Mona Lisa by Leonardo da Vinci, was on display. To his surprise there was an
empty space where the painting should have been. At 11 o’clock the museurn
authorities realized that the painting had been stolen. The next day headlines
all over the world announced the theft. Actually the Leonardo had been gone for more than twenty-four hours before anyone noticed it was missing. The museum was always closed on Mondays for maintenance. Just before closing time on Sunday three men had entered the museum, where they had hidden themselves in a storeroom. The actual theft was quick and simple. Early the next morning Perrugia removed the pai A. making the copy as old as the original one B. using very old wood panels C. making the copy appear cracked and dirty D. signing the date on the back of the original painting [单项选择]下列对钢筋混凝土基础的表述中,不正确的是( )。
A. 钢筋混凝土基础也称为柔性基础 B. 钢筋混凝土基础的断面,可做成锥形,也可做成阶梯形 C. 在相同条件下,采用钢筋混凝土基础比混凝土基础可节省大量的混凝土材料 D. 在相同条件下,采用钢筋混凝土基础比混凝土基础所需的挖土工程量大 [单选题]某项目打算采用甲工艺进行施工,但经广泛的市场调研和技术论证后,决定用乙工艺代替甲工艺,并达到了同样的施工质量,且成本下降15%。根据价值工程原理,该项目提高价值的途径是( )。
A.功能不变,成本降低 B.功能提高,成本降低 C.功能和成本均下降,但成本降低幅度更大 D.功能提高,成本不变 [单选题]GVHR主要见于
A.骨髓移植 B.肾移植 C.心脏移植 D.肝脏移植 E.肺脏移植 [填空题]What does "the rich were keep most of the profits" mean
A. A.It means that the buying power was not defused throughout the economy B.It means the economy was booming C.It means breaking down the traditional American value of saving for a rainy day. [单选题]发生牵引变流器故障2(005)以下哪项处理正确( )。
A.RS复位2-3次 B.闭合VCB C.切除相应M车 D.以上都正确 [单项选择]对肺泡气中的O2(下标)和CO2(下标)分压的过度变化起缓冲作用的是
A. 余气量 B. 肺活量 C. 功能余气量 D. 用力肺活量 E. 补呼气量 [单选题]男,30岁,触电后心肺复苏,心电图示心室颤动,首要的处理措施是 ? ( 1.0 分)
A.用阿托品 B.用肾上腺素 C.除颤 D.用利度卡因 [单选题]排卵前血液中黄体生成素出现高峰的原因是
A.血中孕激素对腺垂体的正反馈作用 B.血中高水平雌激素对腺垂体的正反馈作用 C.血中雌激素和孕激素共同作用 D.卵泡刺激素的作用 [单项选择]患者胞睑内生硬结半年,皮色如常,按之不痛,与睑皮肤不粘连最合适的治疗方法是()
A. 热敷 B. 局部按摩 C. 点眼药水 D. 手术切除 E. 涂眼药膏 [单选题]仪器的测量重复性以单次测量的标准差表示,其值不应超过误差的( )。
A.A、1/4 B.B、1/3 C.C、1/2 D.D、2/4 我来回答: 提交
|