2010计算机等考二级C:50套上机程序填空题(4)
21、给定程序中,函数fun的功能是:将形参n所指变量中,各位上为偶数的数去除,剩余的数按原来从高位到低位的顺序组成一个新的数,并通过形参指针n传回所指变量。
例如,输入一个数:27638496,新的数:为739。
请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
#include
void fun(unsigned long *n)
{ unsigned long x=0, i; int t;
i=1;
while(*n)
/**********found**********/
{ t=*n % __1__;
/**********found**********/
if(t%2!= __2__)
{ x=x t*i; i=i*10; }
*n =*n /10;
}
/**********found**********/
*n=__3__;
}
main()
{ unsigned long n=-1;
while(n>99999999||n<0)
{ printf("Please input(0
fun(&n);
printf("nThe result is: %ldn",n);
}
22、给定程序中,函数fun的功能是:利用指针数组对形参ss所指字符串数组中的字符串按由长到短的顺序排序,并输出排序结果。ss所指字符串数组****有N个字符串,且串长小于M。
请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
#include
#include
#define N 5
#define M 8
void fun(char (*ss)[M])
{ char *ps[N],*tp; int i,j,k;
for(i=0; i
for(i=0; i
/**********found**********/
k= __1__ ;
for(j=i 1; j
/**********found**********/
if(strlen(ps[k]) < strlen(__2__) ) k=j;
/**********found**********/
tp=ps[i]; ps[i]=ps[k]; ps[k]= __3_
