问题 问答题

【说明】 下面的程序按照以下规则输出给定名词的复数形式。 a.若名词以“y”结尾,则删除y并添加“ies”; b.若名词以“s”、“ch”或“sh”结尾,则添加“es”; c.其他所有情况,直接添加“s”。【C程序】 #include <stdio.h> #include <string.h> char*plural(char *word) { int n; char *pstr; n=strlen(word); /*求给定单词的长度*/ pstr=(char*)malloc(n+3);/*申请给定单词的复数形式存储空间*/ if (!pstr||n<2)return NULL; strcpy(pstr,word); /*复制给定单词*/ if ( (1) ) {pstr[n-1]=’i’;pstr[n] =’e’;pstr[n+1]=’s’; (2) ; } elseif(pstr[n-1]==’s’| |pstr[n-1]==’h’&&( (3) )){ pstr[n]=’e’;pstr[n+1]=’s’;pstr[n+2]=’\0’;}else { pstr[n]=’s’;pstr[n+1]=’\0’;) (4) ; }main() { int i; char *ps;char wc[9][10]={"chair","dairy","boss","circus","fly","dog","church","clue","dish");for(i = 0;i<9; i++) { ps= (5) ; printf("%s: %s\n",wc[i],ps); /*输出单词及其复数形式*/ free(ps); /*释放空间*/}system("pause"); }

答案

参考答案:

解析:(1)pstr[n-1]=’y’,或*(pstr+n-1)==’y’,或其等价表示 (2)pstr[n+2]=’\0’,或*(pstr+n+2)=’\0’,或其等价表示 (3)pstr[n-2]=’c’||pstr[n-2]=’s’,或其等价表示 (4)return pstr (5)plural(wc[i]),或其等价表示

[分析]: 本题考查C程序设计基本能力和字符串处理基本操作。 C程序中字符串存储在字符数组中,串的结尾需要设置结束标志符号’\0’。若已知串 pstr的长度为n(不包括结束标志),则串中的字符依次存储在pstr[0],pstr[1],...,pstr[n-1]中。因此,名词的最后一个字符pstr[n-1]若等于字符“y”,则按照规则a求其复数形式。下面的if语句处理的是以“y”结尾的名词,因此,空(1)处应填入“pstr[n-1]=’y’”或其等价形式。由于串pstr的长度发生了变化,所以需要设置新的结束标志,空(2)处应填入“pstr[n+2]=’\0’”’或其等价形式。 if( (1) ) { pstr[n-1]= ’I’; pstr[n]= ’e’; pstr[n+1] = ’s’; (2) ; } 显然,下面的if语句处理规则b所示的情况,即串的末尾为“s”、“ch”或“sh”的情形,空(3)处应填入“pstr[n-2]=’c’||pstr[n-2]=’s”或其等价形式。 if(pstr[n-1]==’s’||pstr[n-1]==’h’ && ( (3) )) { pstr[n] = ’e’; pstr[n+1] =’s’; pstr[n+2]=’\0’; } 根据函数“char *plural(char *word)”的定义,最后应将求得的给定名词的复数形式返回给主调函数mae,对于串,应返回串空间的首地址,即返回指针pstr,因此空(4)处应填入“return pstr”。 根据以下代码,空(5)处应调用函数plural(char*word)对指定名词求复数,数组 WC初始化时已设置了名词序列,因此,空(5)处应填入“plural(wc[i])”。 for(i = 0; i < 9; i++) { ps= (5) ; printf("%s: %s\n",wc[i],ps); /*输出单词及其复数形式*/ free(ps); /*释放空间*/ }

单项选择题

Blues Starting my own section of blues recommendations fills me with a creeping sense of guilt and complicity. Why Because I’m a white guy writing about an almost completely black genre-black, at least in its origins and in the artists that brought the blues to its zenith in the 50’s and 60’s Unlike, say jazz or soul , white performers played little or no positive role in the development of the blues. What positive effect whites had been far outweighed by the commercial exploitation and social exclusion blues pioneers met at every crossroads. Further, there have been absolutely no significant white blues performers. A few are only imitators. Most can’t even properly be called blues musician: they played rock , folk , or pop music influenced by the blues , and much of it was unabashedly horrible , Mostly, though , writing about the blues makes me feel complicit in the unseemly, modern "blues revival" , a movement almost completely white and unoriginal , a popular uprising of middle-class , middle-aged (usually drunk) white guys pretending that they know something about oppression , depravity, rebellion , and the contradictory celebration of life arises from those conditions . These things are the essence of the blues, and, being a middle-class, middle-aged white guy I can vouch that we know nearly nothing about them. So why am I here Well, I can also youth that the blues, like all music, is a universal language, and I have come to understand it academically, if not experientially. Eventually, I came to love blues music if only for its influence on music more akin to my world-rhythm and blues, soul, rock-but in its own right too. In a general way , the blues speak to things we all have in common-love , betrayal , anger , death-and , from that perspective , I , too , got a right to sing the blues-just , well , not in public. On the other hand, as mentioned above, the blues world is now dominated by while folks. The records are made by while performers, many of them talented and certainly well- meaning but often sanitized and uninspired in ways anathema to the blues. White blues musicians frequently teeter on the precipice of caricature. Like Amos N’ Andy they trade in grossly rendered black mannerisms; that they do it out of love for the form rather than derision of the race seems a poor excuse. Sadly, though, most modern blues records-the good ones as well as the bad-are sold almost exclusively to white folks, too. The black audience for blues music has dwindled down to an older, mainly southern crowd of diehard. So, let’s be honest. I come to praise that original style. Indeed, in my research and writing, I hope to increase my own understanding and appreciation for it. And I hold no particular grudge against modern blues, though modern players will be few and far between among my recommendations Mainly, I cannot ignore the fact that modern blues fans made rich men out of John Lee Hooker, B, B, King, Buddy Guy, and other deserving old masters. But, also, there are modern artists who have made great blues records, Many of these artists are from my home state of Texas, so it seems unpatriotic, if not dishonest, not to acknowledge this fact.

According to the author, the essence of the blues is something about ______.

A.the whites

B.the blacks

C.imitation, development and celebration

D.oppression, depravity and rebellion

单项选择题