電大開放教育C++語言程序設(shè)計(jì)期末考試試題及答案資料參考_第1頁
電大開放教育C++語言程序設(shè)計(jì)期末考試試題及答案資料參考_第2頁
電大開放教育C++語言程序設(shè)計(jì)期末考試試題及答案資料參考_第3頁
電大開放教育C++語言程序設(shè)計(jì)期末考試試題及答案資料參考_第4頁
電大開放教育C++語言程序設(shè)計(jì)期末考試試題及答案資料參考_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、C+語言程序設(shè)計(jì) 期末考試試題及答案姓名 _ 學(xué)號(hào) _ 班號(hào) _ 題 號(hào)一二(1)二(2)三總 分成 績一、填空1在類中必須聲明成員函數(shù)的 原型 ,成員函數(shù)的 實(shí)現(xiàn) 部分可以寫在類外。2如果需要在被調(diào)函數(shù)運(yùn)行期間,改變主調(diào)函數(shù)中實(shí)參變量的值,則函數(shù)的形參應(yīng)該是 引用 類型或 指針 類型。3 抽象 類只能作為基類使用,而不能聲明它的對(duì)象。4進(jìn)行函數(shù)重載時(shí),被重載的同名函數(shù)如果都沒有用const修飾,則它們的形參 個(gè)數(shù) 或 類型 必須不同。5通過一個(gè) 常 對(duì)象只能調(diào)用它的常成員函數(shù),不能調(diào)用其他成員函數(shù)。6函數(shù)的遞歸調(diào)用是指函數(shù)直接或間接地調(diào)用 自身 。7拷貝構(gòu)造函數(shù)的形參必須是 本類對(duì)象的引用

2、。二、閱讀下列程序,寫出其運(yùn)行時(shí)的輸出結(jié)果 如果程序運(yùn)行時(shí)會(huì)出現(xiàn)錯(cuò)誤,請(qǐng)簡要描述錯(cuò)誤原因。1請(qǐng)?jiān)谝韵聝深}中任選一題,該題得分即為本小題得分。如兩題都答,則取兩題得分之平均值為本小題得分。(1)程序:#include #include class Base private: char msg30; protected: int n; public: Base(char s,int m=0):n(m) strcpy(msg,s); void output(void) coutnendlmsgendl; ;class Derived1:public Baseprivate:int n;public:

3、Derived1(int m=1):Base(Base,m-1) n=m; void output(void) coutnendl; Base:output();class Derived2:public Derived1private:int n;public:Derived2(int m=2):Derived1(m-1) n=m; void output(void) coutnendl; Derived1:output();int main()Base B(Base Class,1);Derived2 D;B.output();D.output();運(yùn)行結(jié)果:1Base Class210B

4、ase(2)程序:#include class Samppublic:void Setij(int a,int b)i=a,j=b;Samp()coutDestroying.iendl;int GetMuti()return i*j; protected:int i;int j;int main()Samp *p;p=new Samp5;if(!p)coutAllocation errorn;return 1;for(int j=0;j5;j+)pj.Setij(j,j);for(int k=0;k5;k+)coutMutik is: pk.GetMuti()endl;deletep;retu

5、rn 0;運(yùn)行結(jié)果:Muti0 is:0Muti1 is:1Muti2 is:4Muti3 is:9Muti4 is:16Destroying.4Destroying.3Destroying.2Destroying.1Destroying.02請(qǐng)?jiān)谝韵聝深}中任選一題,該題得分即為本小題得分。如兩題都答,則取兩題得分之平均值為本小題得分。(1)程序:#include #include class Vector public: Vector(int s=100); int& Elem(int ndx); void Display(void); void Set(void); Vector(void

6、); protected: int size; int *buffer;Vector:Vector(int s)buffer=new intsize=s;int& Vector:Elem(int ndx)if(ndx=size)couterror in indexendl;exit(1);return bufferndx;void Vector:Display(void)for(int j=0; jsize; j+)coutElem(j)endl;void Vector:Set(void)for(int j=0; jsize; j+)Elem(j)=j+1;Vector:Vector(void

7、)delete buffer;int main()Vector a(10);Vector b(a);a.Set();b.Display();運(yùn)行結(jié)果:12345678910最后出現(xiàn)錯(cuò)誤信息,原因是:聲明對(duì)象b是進(jìn)行的是淺拷貝,b與a共用同一個(gè)buffer,程序結(jié)束前調(diào)用析構(gòu)函數(shù)時(shí)對(duì)同一內(nèi)存區(qū)進(jìn)行了兩次釋放。(2)程序:#includeclass CAT public: CAT(); CAT(const &CAT); CAT(); int GetAge() return *itsAge; void SetAge( int age ) *itsAge=age; protected: int * i

8、tsAge;CAT:CAT()itsAge=new int;*itsAge=5;CAT:CAT()delete itsAge;itsAge=NULL;int main()CAT a;coutas age:a.GetAge()endl;a.SetAge(6);CAT b(a);coutas age:a.GetAge()endl;coutbs age:b.GetAge()endl;a.SetAge(7);coutas age:a.GetAge()endl;coutbs age:b.GetAge()endl;運(yùn)行結(jié)果:as age:5as age:6bs age:6as age:7bs age:7最

9、后出現(xiàn)錯(cuò)誤信息,原因是:聲明對(duì)象b是進(jìn)行的是淺拷貝,b與a共用同一個(gè)buffer,程序結(jié)束前調(diào)用析構(gòu)函數(shù)時(shí)對(duì)同一內(nèi)存區(qū)進(jìn)行了兩次釋放。三、閱讀下列程序及說明和注釋信息,在方框中填寫適當(dāng)?shù)某绦蚨?,使程序完成指定的功?程序功能說明:從鍵盤讀入兩個(gè)分別按由小到大次序排列的整數(shù)序列,每個(gè)序列10個(gè)整數(shù),整數(shù)間以空白符分隔。用這兩個(gè)序列分別構(gòu)造兩個(gè)單鏈表,每個(gè)鏈表有10個(gè)結(jié)點(diǎn),結(jié)點(diǎn)的數(shù)據(jù)分別按由小到大次序排列。然后將兩個(gè)鏈表合成為一個(gè)新的鏈表,新鏈表的結(jié)點(diǎn)數(shù)據(jù)仍然按由小到大次序排列。最后按次序輸出合并后新鏈表各結(jié)點(diǎn)的數(shù)據(jù)。 程序運(yùn)行結(jié)果如下,帶下劃線部分表示輸入內(nèi)容,其余是輸出內(nèi)容:1 3 5 7 9

10、 11 13 15 17 192 4 6 8 10 12 14 16 18 201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20#include #include /類定義部分template class Node private: Node *next; /指向后繼節(jié)點(diǎn)的指針 public: T data; /數(shù)據(jù)域 Node (const T& item, Node* ptrnext = NULL); / 構(gòu)造函數(shù) void InsertAfter(Node *p); /在本節(jié)點(diǎn)之后插入一個(gè)同類節(jié)點(diǎn)p Node *DeleteAfter(

11、void); /刪除本節(jié)點(diǎn)的后繼節(jié)點(diǎn),返回其地址 Node *NextNode(void) const; / 獲取后繼節(jié)點(diǎn)的地址;template class LinkedList private: Node *front, *rear; / 表頭和表尾指針 Node *prevPtr, *currPtr; /記錄表當(dāng)前遍歷位置的指針,由插入和刪除操作更新 int size; / 表中的元素個(gè)數(shù) int position; / 當(dāng)前元素在表中的位置序號(hào)。由函數(shù)Reset使用 Node *GetNode(const T& item,Node *ptrNext=NULL); / 生成新節(jié)點(diǎn),數(shù)據(jù)域

12、為item,指針域?yàn)閜trNext void FreeNode(Node *p); /釋放節(jié)點(diǎn) void CopyList(const LinkedList& L); / 將鏈表L 拷貝到當(dāng)前表 /(假設(shè)當(dāng)前表為空)。被拷貝構(gòu)造函數(shù)、operator=調(diào)用 public: LinkedList(void); / 構(gòu)造函數(shù) LinkedList(const LinkedList& L); /拷貝構(gòu)造函數(shù) LinkedList(void); / 析構(gòu)函數(shù) LinkedList& operator= (const LinkedList& L);/重載賦值運(yùn)算符 int ListSize(void)

13、const; /返回鏈表中元素個(gè)數(shù)(size) int ListEmpty(void) const; /size為0時(shí)返回TRUE,否則返回FALSE void Reset(int pos = 0); /將指針currPtr移動(dòng)到序號(hào)為pos的節(jié)點(diǎn), /prevPtr相應(yīng)移動(dòng),position記錄當(dāng)前節(jié)點(diǎn)的序號(hào) void Next(void); /使prevPtr和currPtr移動(dòng)到下一個(gè)節(jié)點(diǎn) int EndOfList(void) const; / currPtr等于NULL時(shí)返回TRUE, 否則返回FALSE int CurrentPosition(void) const; /返回?cái)?shù)據(jù)成

14、員position void InsertFront(const T& item); /在表頭插入一個(gè)數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn) void InsertRear(const T& item); /在表尾添加一個(gè)數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn) void InsertAt(const T& item); /在當(dāng)前節(jié)點(diǎn)之前插入一個(gè)數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn) void InsertAfter(const T& item); /在當(dāng)前節(jié)點(diǎn)之后插入一個(gè)數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn) T DeleteFront(void); /刪除頭節(jié)點(diǎn),釋放節(jié)點(diǎn)空間,更新prevPtr、currPtr和size void DeleteAt(vo

15、id); /刪除當(dāng)前節(jié)點(diǎn),釋放節(jié)點(diǎn)空間,更新prevPtr、currPtr和size T& Data(void); / 返回對(duì)當(dāng)前節(jié)點(diǎn)成員data的引用 void ClearList(void); / 清空鏈表:釋放所有節(jié)點(diǎn)的內(nèi)存空間。;/類實(shí)現(xiàn)部分略.template void MergeList(LinkedList* la, LinkedList* lb,LinkedList* lc)/合并鏈表la和lb,構(gòu)成新鏈表lc。/函數(shù)結(jié)束后,程序的數(shù)據(jù)所占內(nèi)存空間總數(shù)不因此函數(shù)的運(yùn)行而增加。 while ( !la-ListEmpty() &!lb-ListEmpty() if (la-Dat

16、a()Data() lc-InsertRear(la-Data(); la-DeleteAt(); else lc-InsertRear(lb-Data(); lb-DeleteAt(); while ( !la-ListEmpty() ) lc-InsertRear(la-Data(); la-DeleteAt(); while ( !lb-ListEmpty() ) lc-InsertRear(lb-Data(); lb-DeleteAt();int main() LinkedList la, lb, lc; int item, i;/讀如數(shù)據(jù)建立鏈表la for (i=0;i item;

17、 la.InsertRear(item); la.Reset();/讀如數(shù)據(jù)建立鏈表lb for (i=0;i item; lb.InsertRear(item); lb.Reset();MergeList(&la, &lb, &lc);/合并鏈表 lc.Reset();/ 輸出各節(jié)點(diǎn)數(shù)據(jù),直到鏈表尾 while(!lc.EndOfList() cout lc.Data() ; lc.Next(); / 使currPtr指向下一個(gè)節(jié)點(diǎn) cout endl;請(qǐng)您刪除一下內(nèi)容,O(_)O謝謝!2016年中央電大期末復(fù)習(xí)考試小抄大全,電大期末考試必備小抄,電大考試必過小抄Basketball can

18、 make a true claim to being the only major sport that is an American invention. From high school to the professional level, basketball attracts a large following for live games as well as television coverage of events like the National Collegiate Athletic Association (NCAA) annual tournament and the

19、 National Basketball Association (NBA) and Womens National Basketball Association (WNBA) playoffs. And it has also made American heroes out of its player and coach legends like Michael Jordan, Larry Bird, Earvin Magic Johnson, Sheryl Swoopes, and other great players. At the heart of the game is the

20、playing space and the equipment. The space is a rectangular, indoor court. The principal pieces of equipment are the two elevated baskets, one at each end (in the long direction) of the court, and the basketball itself. The ball is spherical in shape and is inflated. Basket-balls range in size from

21、28.5-30 in (72-76 cm) in circumference, and in weight from 18-22 oz (510-624 g). For players below the high school level, a smaller ball is used, but the ball in mens games measures 29.5-30 in (75-76 cm) in circumference, and a womens ball is 28.5-29 in (72-74 cm) in circumference. The covering of t

22、he ball is leather, rubber, composition, or synthetic, although leather covers only are dictated by rules for college play, unless the teams agree otherwise. Orange is the regulation color. At all levels of play, the home team provides the ball. Inflation of the ball is based on the height of the ba

23、lls bounce. Inside the covering or casing, a rubber bladder holds air. The ball must be inflated to a pressure sufficient to make it rebound to a height (measured to the top of the ball) of 49-54 in (1.2-1.4 m) when it is dropped on a solid wooden floor from a starting height of 6 ft (1.80 m) measur

24、ed from the bottom of the ball. The factory must test the balls, and the air pressure that makes the ball legal in keeping with the bounce test is stamped on the ball. During the intensity of high school and college tourneys and the professional playoffs, this inflated sphere commands considerable a

25、ttention. Basketball is one of few sports with a known date of birth. On December 1, 1891, in Springfield, Massachusetts, James Naismith hung two half-bushel peach baskets at the opposite ends of a gymnasium and out-lined 13 rules based on five principles to his students at the International Trainin

26、g School of the Young Mens Christian Association (YMCA), which later became Springfield College. Naismith (1861-1939) was a physical education teacher who was seeking a team sport with limited physical contact but a lot of running, jumping, shooting, and the hand-eye coordination required in handlin

27、g a ball. The peach baskets he hung as goals gave the sport the name of basketball. His students were excited about the game, and Christmas vacation gave them the chance to tell their friends and people at their local YMCAs about the game. The association leaders wrote to Naismith asking for copies

28、of the rules, and they were published in the Triangle, the school newspaper, on January 15,1892. Naismiths five basic principles center on the ball, which was described as large, light, and handled with the hands. Players could not move the ball by running alone, and none of the players was restrict

29、ed against handling the ball. The playing area was also open to all players, but there was to be no physical contact between players; the ball was the objective. To score, the ball had to be shot through a horizontal, elevated goal. The team with the most points at the end of an allotted time period

30、 wins. Early in the history of basketball, the local YMCAs provided the gymnasiums, and membership in the organization grew rapidly. The size of the local gym dictated the number of players; smaller gyms used five players on a side, and the larger gyms allowed seven to nine. The team size became gen

31、erally established as five in 1895, and, in 1897, this was made formal in the rules. The YMCA lost interest in supporting the game because 10-20 basketball players monopolized a gymnasium previously used by many more in a variety of activities. YMCA membership dropped, and basketball enthusiasts pla

32、yed in local halls. This led to the building of basketball gymnasiums at schools and colleges and also to the formation of professional leagues. Although basketball was born in the United States, five of Naismiths original players were Canadians, and the game spread to Canada immediately. It was pla

33、yed in France by 1893; England in 1894; Australia, China, and India between 1895 and 1900; and Japan in 1900. From 1891 through 1893, a soccer ball was used to play basketball. The first basketball was manufactured in 1894. It was 32 in (81 cm) in circumference, or about 4 in (10 cm) larger than a s

34、occer ball. The dedicated basketball was made of laced leather and weighed less than 20 oz (567 g). The first molded ball that eliminated the need for laces was introduced in 1948; its construction and size of 30 in (76 cm) were ruled official in 1949. The rule-setters came from several groups early

35、 in the 1900s. Colleges and universities established their rules committees in 1905, the YMCA and the Amateur Athletic Union (AAU) created a set of rules jointly, state militia groups abided by a shared set of rules, and there were two professional sets of rules. A Joint Rules Committee for colleges

36、, the AAU, and the YMCA was created in 1915, and, under the name the National Basketball Committee (NBC) made rules for amateur play until 1979. In that year, the National Federation of State High School Associations began governing the sport at the high school level, and the NCAA Rules Committee as

37、sumed rule-making responsibilities for junior colleges, colleges, and the Armed Forces, with a similar committee holding jurisdiction over womens basketball. Until World War II, basketball became increasingly popular in the United States especially at the high school and college levels. After World

38、War II, its popularity grew around the world. In the 1980s, interest in the game truly exploded because of television exposure. Broadcast of the NCAA Championship Games began in 1963, and, by the 1980s, cable television was carrying regular season college games and even high school championships in

39、some states. Players like Bill Russell, Wilt Chamberlain, and Lew Alcindor (Kareem Abdul-Jabbar) became nationally famous at the college level and carried their fans along in their professional basketball careers. The womens game changed radically in 1971 when separate rules for women were modified

40、to more closely resemble the mens game. Television interest followed the women as well with broadcast of NCAA championship tourneys beginning in the early 1980s and the formation of the WNBA in 1997. Internationally, Italy has probably become the leading basketball nation outside of the United State

41、s, with national, corporate, and professional teams. The Olympics boosts basketball internationally and has also spurred the womens game by recognizing it as an Olympic event in 1976. Again, television coverage of the Olympics has been exceptionally important in drawing attention to international te

42、ams. The first professional mens basketball league in the United States was the National Basketball League (NBL), which debuted in 1898. Players were paid on a per-game basis, and this league and others were hurt by the poor quality of games and the ever-changing players on a team. After the Great D

43、epression, a new NBL was organized in 1937, and the Basketball Association of America was organized in 1946. The two leagues came to agree that players had to be assigned to teams on a contract basis and that high standards had to govern the game; under these premises, the two joined to form the Nat

44、ional Basketball Association (NBA) in 1949. A rival American Basketball Association (ABA) was inaugurated in 1967 and challenged the NBA for college talent and market share for almost ten years. In 1976, this league disbanded, but four of its teams remained as NBA teams. Unification came just in tim

45、e for major television support. Several womens professional leagues were attempted and failed, including the Womens Professional Basketball League (WBL) and the Womens World Basketball Association, before the WNBA debuted in 1997 with the support of the NBA. James Naismith, originally from Al-monte,

46、 Ontario, invented basketball at the International YMCA Training School in Springfield, Massachusetts, in 1891. The game was first played with peach baskets (hence the name) and a soccer ball and was intended to provide indoor exercise for football players. As a result, it was originally a rough spo

47、rt. Although ten of Naismiths original thirteen rules remain, the game soon changed considerably, and the founder had little to do with its evolution. The first intercollegiate game was played in Minnesota in 1895, with nine players to a side and a final score of nine to three. A year later, the fir

48、st five-man teams played at the University of Chicago. Baskets were now constructed of twine nets but it was not until 1906 that the bottom of the nets were open. In 1897, the dribble was first used, field goals became two points, foul shots one point, and the first professional game was played. A y

49、ear later, the first professional league was started, in the East, while in 1900, the first intercollegiate league began. In 1910, in order to limit rough play, it was agreed that four fouls would disqualify players, and glass backboards were used for the first time. Nonetheless, many rules still di

50、ffered, depending upon where the games were played and whether professionals, collegians, or YMCA players were involved. College basketball was played from Texas to Wisconsin and throughout the East through the 1920s, but most teams played only in their own regions, which prevented a national game o

51、r audience from developing. Professional basketball was played almost exclusively in the East before the 1920s, except when a team would barnstorm into the Midwest to play local teams, often after a league had folded. Before the 1930s very few games, either professional or amateur, were played in fa

52、cilities suitable for basketball or with a perfectly round ball. Some were played in arenas with chicken wire separating the players from fans, thus the word cagers, others with posts in the middle of the floor and often with balconies overhanging the corners, limiting the areas from which shots cou

53、ld be taken. Until the late 1930s, all players used the two-hand set shot, and scores remained low. Basketball in the 1920s and 1930s became both more organized and more popular, although it still lagged far behind both baseball and college football. In the pros, five urban, ethnic teams excelled an

54、d played with almost no college graduates. They were the New York Original Celtics; the Cleveland Rosenblums, owned by Max Rosenblum; Eddie Gottliebs Philadelphia SPHAs (South Philadelphia Hebrew Association); and two great black teams, the New York Renaissance Five and Abe Sapersteins Harlem Globet

55、rotters, which was actually from Chicago. While these teams had some notable players, no superstars, such as Babe Ruth, Jack Dempsey, or Red Grange, emerged to capture the publics attention as they did in other sports of the period. The same was true in college basketball up until the late 1930s, wi

56、th coaches dominating the game and its development. Walter Doc Meanwell at Wisconsin, Forrest Phog Allen at Kansas, Ward Piggy Lambert at Purdue, and Henry Doc Carlson at Pittsburgh all made significant contributions to the games development: zone defenses, the weave, the passing game, and the fast

57、break. In the decade preceding World War II, five events changed college basketball and allowed it to become a major spectator sport. In 1929, the rules committee reversed a decision that would have outlawed dribbling and slowed the game considerably. Five years later, promoter Edward Ned Irish stag

58、ed the first intersectional twin bill in Madison Square Garden in New York City and attracted more than 16,000 fans. He demonstrated the appeal of major college ball and made New York its center. In December 1936, Hank Luisetti of Stanford revealed the virtues of the one-handed shot to an amazed Gar

59、den audience and became the first major collegiate star. Soon thereafter, Luisetti scored an incredible fifty points against Duquesne, thus ending the Easts devotion to the set shot and encouraging a more open game. In consecutive years the center jump was eliminated after free throws and then after

60、 field goals, thus speeding up the game and allowing for more scoring. In 1938, Irish created the National Invitation Tournament (NIT) in the Garden to determine a national champion. Although postseason tournaments had occurred before, the NIT was the first with major colleges from different regions

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論