问题 单项选择题

有以下程序:
#include<iostream>
using namespace std;
int f(int,int);
int main()

int i:1,x;
x=f(i,i+1);
cout<<x<<end1;
return 0;

int f(int a,int b)

int c;
c = a;
if(a>b)
c = 1;
else if(a==b)
c = 0;
else
c = -2;
return c;

运行后的输出结果是( )。

A.1

B.0

C.-1

D.-2

答案

参考答案:D

解析: 本题考核对函数调用方法的掌握程度。做此类题主要是弄清楚程序每一步的目的:在主函数前面声明了整型函数f。在主函数中,调用了函数f()。实参的值分别是1和2,1传给函数f的形参a,2传给函数f的形参b,函数返回的值赋给变量x。即为输出的函数值。
具体分析一下函数f()的功能:如果a大于b,则赋予c的值为1;并且跳出if-else语句。如果a不大于b,则进入else if分支中,如果a等于b,则赋予c的值为0,
并跳出以下的if-else语句。如果a不等于b,则进入else分支,执行c=-2。因为实参1,2分别传给形参a,b,所以此时a<b,f()函数应执行c=-2。即最终输出应为-2。

选择题
单项选择题

The United States is usually given credit for creating and developing the musical comedy as it is known today. The first musical shows were based (1) everyday American life and the (2) development of the form took place in the United States for more than half a century. (3) the early 1970s, (4) , the London theater has (5) the Broadway stage.

The Black Crook, which opened at Niblo’s Garden in New York City on Sept. 12, 1866, is usually (6) as the inspiration for musical comedy. A troupe of French ballet dancers (7) to be stranded in New York without work (8) a fire damaged the theater (9) they had been booked. In order to keep a (10) to them, the theater producer put the dancers into a melodrama written by Charles M. Barres.

The first stage production that was (11) a musical comedy was a show that was (12) from the Prince of Wales Theater to the Gaiety Theater in London in 1892. Staged by George Edwards, the show called In Town featured a chorus line of Gaiety Girls. The (13) year A Gaiety Girl was equally successful, and a (14) of the show played in New York in the same year. When it was (15) in newspapers, it was designated a musical comedy and regarded as a new (16) of entertainment.

It did not take the form long to (17) in the United States. Almost (18) one of the most renowned talents of the American stage went to work on his own musicals. The singer-dancer George M. Cohan staged Little Johnny Jones in 1904. Cohan, (19) own life story was made into the musical George M (1968), also wrote the books, words, and (20) for Forty-five Minutes from Broadway ( 1906 ), The Little Millionaire ( 1911 ), The Song and Dance Man ( 1923 ), and American Born (1925).

8()

A.because

B.thus

C.but

D.hence