[说明]对于具有n个元素的整型数组a,需要进行的处理是删除a中所有的值为0的数组元素

题型:填空题

问题:

[说明]

对于具有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)。

根据CompactArr_v2的处理思路填补空缺(4)。

考点:计算机软件水平考试初级程序员初级程序员2011上半年下午试题
题型:填空题

阅读理解。

     With fluent Chinese, practiced skills(技巧) on Chinese expressions and special humor in a Beijing

accent, Dashan has become a famous name across China.

     People have always wondered how the Canadian can be so good at the Chinese language. It is

considered by many people as one of the most difficult languages in the world. But to Dashan, the great

difficulty was a piece of cake because of his deep interest, proper ways and the good environment he

made for himself.

     “Interest is the best teacher.” Deeply interested in Chinese culture, Dashan decided to study in

Beijing. When he entered the Chinese Department of Beijing University in 1988, Dashan felt like a duck

in water. Study is a hard job, no matter how much interest you have. Therefore, effective ways are

necessary. As a new student, he did study the textbooks. However, that’s not enough to learn the

Chinese language well. Dashan began to read original(原版)Chinese novels, Chinese newspapers

and even works of Deng Xiaoping. “Only the material for Chinese native readers could give me a proper

sense of the language,” he said. “What you have really learned depends on what you can use. To listen

and speak as much as possible does help.”

     To help Chinese English learners, Dashan took part in a VCD program-Travel with Dashan-to teach

daily and up-to-date English in real life situations.

1. Dashan could learn Chinese very well because of _______. 

A. his VCD program                

B. his practiced skills on Chinese expressions

C. his interest and proper ways        

D. his special humour with a Beijing accen

2. It is very difficult for most people to learn Chinese but it is _______to Dashan. 

A. a joyful thing                    

B. an easy thing

C. a difficult thing                  

D. an exciting thing

3. Dashan read the works of Deng Xiaoping because _______.

A. he liked the former leader of the government

B. he hoped to learn more information of it

C. he wanted to give himself a proper sense of Chinese  

D. they are very popular in modern times

4. The main idea of the passage is _______. 

A. how Dashan learned the Chinese language so well

B. how we can master a foreign language in a short time

C. Dashan took part in a VCD program to teach English

D. try to learn English like Dashan, and you will succeed 

题型:填空题

《道路交通安全法》中称“非机动车”是指()

A.以人力驱动上道路行驶的交通工具

B.以畜力驱动上道路行驶的交通交通工具

C.设计最高时速、空车质量、外形尺寸符合有关国家标准的残疾人机动轮椅车

D.设计最高时速、空车质量、外形尺寸符合有关国家标准的电动自行车

题型:填空题

环道试验

题型:填空题

()是选择和确定训练方法的基本原则。

A.训练对象

B.训练设施

C.训练内容

D.训练目的

题型:填空题

我党坚持人民的利益高于一切,坚持()

A一切为了群众

B一切依靠群众

C一切给予人民

D从群众中来到群众中去

更多题库