问题 填空题

在下面函数的横线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度 (不得使用系统提供的字符串处理函数)。 int GetLen(char*str) { if(______)return ______; else return 1+GetLen(str+1); }

答案

参考答案:*str==NULL或!*str或*str==0或*sir==’0’或str[0]==’\0’或str[0]==或str[0] ==ULL0

解析: 本题考核递归函数的定义。递归函数GetLen的定义中给出了递归方式,但缺少递归终止的条件,所以横线处应填入的递归终止的条件。显然此函数递归终止的条件是读到了字符串的终止符’/0’,此时返回的值为0

单项选择题
单项选择题

People can get emotional about immigration. Bill O’Reilly, a talk-show host, devoted a recent segment to the story of an illegal alien who got drunk and accidentally killed two attractive white girls with his car. If only he had been deported for previous misdemeanours, Mr. O’Reilly raged, those girls would still be alive. Another talk-show host, Geraldo Rivera, during an on-air shout-joust(争吵) with Mr. O’ Reilly, denounced his demagogic choice of story-angle as" a sin".

President George Bush tried again this week to bring a more rational tone to the debate. He urged the new Democratic Congress to revive the immigration reforms that the old Republican Congress killed last year. His proposal was broadly the same as before. He said he wanted to make it harder to enter America illegally, but easier to do so legally, and to offer a path to citizenship for the estimated 12m illegals who have already snuck in.

The first part faces few political hurdles and is already well under way. Mr. Bush expects to have doubled the number of Border Patrol agents by the end of next year. The new recruits are being trained. And to defend against the invading legions of would-be gardeners and hotel cleaners, the frontier is also equipped with high-tech military gizmos(小发明), such as unmanned spy planes with infra-red(红外) cameras. This may be having some effect. Mr. Bush boasted that the number of people caught sneaking over the border had fallen by nearly 30% this year.

And the controversial part of Mr. Bush’s immigration package--allowing more immigrants in and offering those already in America a chance to become legal -- is still just a plan. House Republicans squashed it last year. Mr. Bush senses a second chance with the new Democratic Congress, but Democrats, like Republicans, are split on the issue. Some, notably Ted Kennedy, think America should embrace hard- working migrants. Others fret that hard-working migrants will undercut the wages of the native-born.

Mr. Bush would like to see the pro-immigrant wings of both parties work together to give him a bill he can sign. The Senate is expected to squeeze in a debate next month. The administration is trying to entice law-and-order Republicans on board; a recent leaked memo talked of substantial fines for illegals before they can become legal and" much bigger" fines for employers who hire them before they do.

The biggest hurdle, however, may be the Democrats’ reluctance to co-operate with Mr. Bush. Some figure that, rather than letting their hated adversary share the credit for fixing the immigration system, they should stall until a Democrat is in the White House and then take it all. So there is a selfish as well as a moral argument for making a deal.

Which of the following is proposed by Mr. Bush()

A. Making it harder for immigrants to enter America both legally and illegally

B. Carrying out substantial fine for illegals before they can become legal

C. Setting up more Border Patrol agents by the end of this year

D. Allowing more immigrants in and offering them a chance to become legal