问题 问答题

请编写函数fun(),其功能是:将s所指字符串中除了下标为奇数、同时ASCII值为偶数的字符外,其余的全部删除,串中剩余字符所形成的一个新串放在t所指的数组中。 例如,若s所指字符串中的内容为edB2A4Dsdg,其中字符A的ASCII码值为奇数,因此应当删除;其中字符B的ASCII码值为偶数,但在数组中的下标为偶数,因此也应当删除:而字符2的ASCII码值为偶数,所在数组中的下标为奇数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是d24。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <conio.h> #include <stdio.h> #include<string, h> void fun(char*s, char t[]) { } main() { char s[100] ,t[100]; clrscr(); printf("\nPlease enter string S: "); scanf("%s",s); fun(s,t); printf("\nThe result is: %s\n",t); }

答案

参考答案:

解析:void fun(char*s, char t[]) { int i,j=0; for(i=0;s[i]!=’\0’;i++) if(i%2!=0&&s[i]%2==0) /*将s所指字符串下标为奇数同时ASCII值为偶数的字符放入数组t中*/ t[j++]=s[i]; t[j]=’\0’; /*在字符串最后加上结束标志位*/ } 本题要求除了下标为奇数同时ASCII值为偶数的字符之外,其他字符都删除。即题目要求留下下标为奇数同时 ASCII值为偶数的字符。C语言中并没有直接删除字符的算法,请大家在做题的时候注意。

阅读理解

Three armed robbers stole two Pablo Picasso prints from an art museum in downtown Sao

Paulo on Thursday, which was the city’s second high-profile art theft in less than a year. The bandits also took two oil paintings by well-know Brazilian artists Emiliano Di Cavalcanti and Lasar Segall, said Carla Regina, a spokeswoman for the Pinacoteca do Estado museum.

The Picasso prints stolen were "The Painter and the Model" from 1963 and "Minotaur, Drinker and Women" from 1933, according to a statement from the Sao Paulo Secretary of State for Culture, which oversees the museum. The prints and paintings have a combined value of $612,000, the statement and a museum official said.

About noon, three armed men paid the $2.45 entrance fee and immediately went to the second-floor gallery where the works were being exhibited, bypassing more valuable pieces, authorities said. "This indicates to us that they probably received an order" to take those specific works, Youssef Abou Chain, head of Sao Paulo's organized crime unit, told reporters at a news conference. The assailants overpowered three unarmed museum guards and grabbed the works, officials said. The robbery took about 10 minutes and the museum was nearly empty at the time. The assailants took the pieces — frames and all — out of the museum in two bags. The institution has no metal detectors.

In December, Picasso's "Portrait of Suzanne Bloch" and "O Lavrador de Cafe" by Candido Portinari, an influential Brazilian artist, were stolen from the Sao Paulo Museum of Art by three men who used a crowbar(铁撬棍)and car jack to force open one of the museum's steel doors. The framed paintings were found Jan. 8, covered in plastic and leaning against a wall in a house on the outskirts of Sao Paulo, South America's largest city. One of the suspects in that robbery — a former TV chef — turned himself over to police in January, who already had two suspects in custody(监禁).

小题1:What did the armed men steal on Thursday?

A.Two prints by Pablo Picasso

B.Two oil painting by Brazilian artists

C.Two prints by Pablo Picasso and two oil paintings by two Brazilian artists.

D.Two prints by two Brazilian artists and two oil paintings by Picasso Pablo.小题2:Why didn't the thieves take other more valuable works?

A.Because they didn't know that the other pieces were worth more.

B.Probably because they had received an order for the prints that they took.

C.Because they didn't have enough time.

D.Because they were in such a hurry that they couldn’t get them all.小题3:How many people were in the museum during the robbery?

A.A lot. The museum was crowded.

B.Not too many. It was almost empty.

C.There were a lot of people outside the museum.

D.Only three of them.小题4:According to the passage, which of the followings is TRUE?

A.In December, "Portrait of Suzanne Bloch" and "O Lavrador de Cafe" painted by Candido

Portinari were stolen.

B.There are steel doors and no detectors in Sao Paulo Museum of Art.

C.Three robbers defeated three armed museum guards and took away the works on Thursday.

D.Three suspects in the first high-profile art theft in less than a year were arrested.

填空题