问题 多项选择题

下列程序的功能是:把s字符串中所有的字符左移一个位置,串中的第一个字符移到最后。请编制函数 chg(char*s)实现程序要求,最后调用函数readwriteDat()把结果输出到out63.dat文件中。
例如:s字符串中原有内容为Mn,123xyZ,则调用该函数后,结果为n,123xyZM。
注意:部分源程序已给出。
请勿改动主函数main()和输入输出函数readwriteDAT()的内容。
试题程序:
#include<conio. h>
#include<stdio. h>
#define N 81
void readwriteDAT(); void chg(char *s)

main ( )

char a [N];
clrscr ();
printf("Enter a string :");
gets (a);
printf("The original string is :");
puts (a);
chg (a);
printf("The string after modified :");
puts (a);
readwriteDAT ( );
void readwriteDAT()
int i;
char a [N];
unsigned char *p;
FILE *rf,*wf;
rf=fopen ("in63.dat", "r");
wf=fopen ("out63.dat", "w");
for (i=0; i<10;i++)
fgets (a, 80, rf);
p=strchr (a, ’ \n’ );
if(p) *p=0;
chg (a);
fprintf (wf, "%s\n", a);

fclose(rf);
fclose (wf);

答案

参考答案:void chg(char *s)
{
int i,strl;
char ch;
strl=strlen (s); /*求字符串的长度*/
ch=*s; /*将第一个字符暂赋给ch* /
for (i=O; i<strl-A; i++) /*将字符依次左移*/
*(s+i) =* (s+i+l);
* (s+strl-A) =ch; /*将第一个字符移到最后*/
}

解析:
(1) 数组中元素的移动。
(2) 指针的使用。
我们可以使用一个循环实现数组中所有字符元素的左移。这里要注意的足第1个字符要移至最后1个字符处,所以首先要将第1个字符保存。在移动时,要从左到右依次移动,否则,左侧的字符会在移动前被其右侧的字符覆盖。在这里使用了指针,初始时,指针指向数组的第1个元素,随着地址的增加指针指向数组后面的元素。例如,若地址加2,

多项选择题
单项选择题

In order to understand, however imperfectly, what is meant by "face", we must take (1) of the fact that, as a race, the Chinese have a ply (2) instinct. The theatre may almost be said to be the only national amusement, and the Chinese have for theatricals a (3) like that of the Englishman (4) athletics, or the Spaniard for bull-fights. Upon very slight provocation, any Chinese regards himself in the (5) of an actor in a drama. He throws himself into theatrical attitudes, performs the salaam, falls upon his knees, prostrates himself and strikes his head upon the earth, (6) circumstances which to an Occidental seem to make such actions superfluous, (7) to say ridiculous. A Chinese thinks in theatrical terms. When roused in self-defense he addresses two or three persons as if they were a multitude. He exclaims: "I say this in the presence of You, and You, and You, who are all here present. " If his troubles are adjusted he (8) of himself as having "got off the stage" with credit, and if they are not adjusted he finds no way to "retire from the stage". All this, (9) it clearly understood, has nothing to do with realities. The question is never of facts, but always of (10) . If a fine speech has been (11) at the proper time and in the proper way, the requirement of the play is met. We are not to go behind the scenes, for that would (12) all the plays in the world. Properly to execute acts like these in all the complex relations of life, is to have "face". To fail them, to ignore them, to be thwarted in the performance of them, this is to " (13) face". Once rightly apprehended, "face" will be found to be in itself a (14) to the combination lock of many of the most important characteristics of the Chinese.

It should be added that the principles which regulate "face" and its attainment are often wholly (15) the intellectual apprehension of the Occidental, who is constantly forgetting the theatrical element, and wandering (16) into the irrelevant regions of fact. To him it often seems that Chinese "face" is not unlike the South Sea Island taboo, a force of undeniable potency, but capricious, and not reducible to rule, deserving only to be abolished and replaced by common sense. At this point Chinese and Occidentals must agree to (17) , for they can never be brought to view the same things in the same light. In the adjustment of the incessant quarrels which distract every hamlet, it is necessary for the "peace-talkers" to take a careful account of the (18) of "face" as European statesmen once did of the balance of power. The object in such cases is not the execution of even-handed justice, which, even if theoretically desirable, seldom (19) to an Oriental as a possibility, but such an arrangement as will distribute to all concerned "face" in due proportions. The same principle often applies in the settlement of lawsuits, a very large percentage of which end in what may be called a (20) game.

16()

A.up

B.off

C.down

D.out