21、給定程序中,函數(shù)fun的功能是:將形參n所指變量中,各位上為偶數(shù)的數(shù)去除,剩余的數(shù)按原來(lái)從高位到低位的順序組成一個(gè)新的數(shù),并通過(guò)形參指針n傳回所指變量。
例如,輸入一個(gè)數(shù):27638496,新的數(shù):為739。
請(qǐng)?jiān)诔绦虻南聞澗€處填入正確的內(nèi)容并把下劃線刪除, 使程序得出正確的結(jié)果。
注意:源程序存放在考生文件夾下的BLANK1.C中。
不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
#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: %ld\n",n);
}
22、給定程序中,函數(shù)fun的功能是:利用指針數(shù)組對(duì)形參ss所指字符串?dāng)?shù)組中的字符串按由長(zhǎng)到短的順序排序,并輸出排序結(jié)果。ss所指字符串?dāng)?shù)組****有N個(gè)字符串,且串長(zhǎng)小于M。
請(qǐng)?jiān)诔绦虻南聞澗€處填入正確的內(nèi)容并把下劃線刪除, 使程序得出正確的結(jié)果。
注意:源程序存放在考生文件夾下的BLANK1.C中。
不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
#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__ ;
}
printf("\nThe string after sorting by length:\n\n");
for(i=0; i
}
main()
{ char ch[N][M]={"red","green","blue","yellow","black"};
int i;
printf("\nThe original string\n\n");
for(i=0;i
fun(ch);
}