问题 问答题

下列给定程序中,函数fun的功能是:将s所指字符串中的所有数字字符移到所有非数字字符之后,并保持数字字符串和非数字字符串原有的次序。
例如,s所指的字符串为“def35adh3kjsdf7”,执行后结果为“defadhkjsdf3537”。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stldio.h>
void fun(char*s)
(
inf j,j=O,k=O;
char tl[80],t2[80];
for(i=0;s[i]!=’\0’;i++)
if(s[i]>=’O’&&s[i]<=’9’)

t2[j]=s[i];
/********found********/
(1) ;

else

tl[k++]=s[i];

t2[j]=O;
t1[k]=O;
for(i=O;i<k;i++)
/********found********/
(2) ;
/********found********/
for(i=0;i< (3) ;i++)
s[k+i]=t2[i];

main()

char s[80)="ba3a54j7sd567sdffs";
printf("\nThe original string is%s\n,s);
fun(s);
printf("\nThe restult is%s\n,s);

答案

参考答案:j++或j+=l或++j或j=j+l
(2)s[i]=t1[i] (3)i

解析:
本题关键字有:指针型变量;数组元素引用;for循环语句。
[微分析]
填空1:数组t1用来存储s中的非数字字符,数组t2用来存储s中的数字字符,下标j加1用来存储后面的数字字符。
填空2:将数字与非数字字符分开保存后,字符串s要先放人非数字字符,所以填入s[i]=t1[i]。
填空3:数字字符的个数是j,所以循环条件i<j。

单项选择题
填空题

For more than two centuries, American’s colleges and universities have been the backbone of the country’s progress. They have educated the technical, managerial, (1) and provided generation after generation of national leaders. Today educators from around the globe are turning to U. S. institutions of higher learning (2) . They are apt to find many reasons for the excellence of American universities, but (3) stand out as watersheds:
Education (4) : In 1862 Congress enacted the Land-Grant College Act, which essentially extended the opportunity of higher education (5) , including such disenfranchised groups as women and minorities. Each state was permitted to sell large tracts of (6) and use the proceeds to endow at least one public college.
(7) : Over the years, the decentralization and diversity of the America’s colleges and universities have promoted competition for students and resources. Competitive pressure first arose (8) . The academy’s impact really grew after World War II, when (9) commissioned by President Roosevelt argued that it was the federal government’s responsibility to (10) for basic research. Instead of being centralized in government laboratories, scientific research (11) in American universities and generated increasing investment. It also gave graduate students research opportunities and helped (12) far and wide, to the benefit of industry, medicine and society as a whole.
(13) : The end of the World War II saw passage of the Servicemen’s Readjustment Act of 1944. The law, which provided for (14) for returning veterans, made an already democratic higher-education system accessible in ways that were (15) in Europe, opening the doors of the best universities to men and women who had (16) of going to college.
(17) : The creation of federal loan guarantees and subsidy programs, as well as outright grants for college students brought (18) to higher education and further helped to democratize access. Since its founding (19) , the Federal Family Education Loan Program has funded more than 74 million student loans worth more than (20) .