




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、電大C+語言程序設計期末考試復習題及參考答案資料小抄一、單選題1 在定義函數(shù)的格式類型修飾符 函數(shù)名 (形式參數(shù)表)函數(shù)體;中,函數(shù)體可以是( )。A、基本語句 B、復合語句C、空語句 D、語句序列2ABAB的值( )。A、為true B、為falseC、與AB 的值相同 D、與AB的值相同3每一個實在參數(shù)就是一個( )。A、表達式 B、常量 C、變量 D、函數(shù)調(diào)用4. 假定AB為一個類,則該類的拷貝構(gòu)造函數(shù)的聲明語句為_。 A AB&(AB x); B AB(AB x) C AB(AB &x); D AB(AB* x)5. 對于結(jié)構(gòu)中定義的成員,其隱含訪問權(quán)限為_。 A pu
2、blic B protected C private D static6當使用fstream流類定義一個流對象并打開一個磁盤文件時,文件的隱含打開方式為_。 A ios:in B ios:out C ios:in | ios:out D 沒有7在PC機中運行的C+ 語言程序,char類型的數(shù)據(jù)占 字節(jié)。A、1 B、2 C、3 D、48指出下列哪種基本類型是錯誤的 B 。A、float B、integer C、char D、long9若a,b,c均為整型變量,則表達式a=2,b=a+2,c=0的值為 。A、不定 B、2 C、4 D、010設char t=A;則表達式5+0.6+t值的數(shù)據(jù)類型為
3、。A、int B、float C、不確定 D、double11以下 為不正確的if語句。A、if (x>y); B、if (x= =y) x+y;C、if (x! = y) cin>>x else cin>>y; D、if(x<y) x+;y+;12指向數(shù)組元素為整型的一維數(shù)組的指針變量的定義是 。A、int *p( ) B、int (*p)( ) C、int *p4 D、int (*p)413以下關于switch語句和break語句的描述中不正確的是 。A、 break語句不能用于循環(huán)語句和switch語句外的任何其它語句B、 switch語句中使用bre
4、ak語句或continue語句的作用相同C、 在循環(huán)語句中使用break語句是為了使流程跳出循環(huán)體,提前結(jié)束循環(huán)D、 在循環(huán)語句中使用continue語句是為了結(jié)束本次循環(huán),而不是終止整個循環(huán)的執(zhí)行。14下列關于函數(shù)定義的說法,正確的是 。A、函數(shù)定義時,可以嵌套 B、函數(shù)定義不可以嵌套,但可以嵌套調(diào)用C、主函數(shù)main()內(nèi)可以定義函數(shù) D、函數(shù)定義可以嵌套,調(diào)用也可以嵌套。15若有以下說明語句int a34=2,3,4,5,3,4,5,6,4,5,6,7;則正確對數(shù)組元素引用為 。A、*(a+1) B、*(a3+2) C、a1+3 D、a0016若定義如下的共同體類型變量x,則x所占用的內(nèi)
5、存字節(jié)數(shù)為 (以IBM PC機為例)union dataint i;char ch;double f;x;A、7 B、11 C、8 D、10二、填空題1應用程序TEST.CPP中只有一個函數(shù),這個函數(shù)的名稱是 main 。25|6,5&6和56的值分別是 7 , 4 和 3 。3不借助于其他變量交換x和y兩個變量的值,應順序執(zhí)行的三個賦值語句是 x=x+y , y=x-y 和 x=x-y 。4下面的語句顯示輸出8行8列數(shù)組h的主對角線上的所有元素,請補充完整:for( i=0 ; i<8 ;i+)cout<< hii <<' ' ;5若一函
6、數(shù)是以return;結(jié)束運行的,說明該函數(shù)是 無參 函數(shù)。6若正常執(zhí)行了如下語句:int m20,*p1=m5,*p2=m+17,n;n=p2-p1; 則n的值為 12 。7已知' A'一'Z'的ASCII碼為6590,當執(zhí)行"char ch=14*5+2;cout<<ch<<endl;"語句序列后,得到的輸出結(jié)果為 H 。8float和double類型的長度分別為 4 和 8 。9表達式xx+l表示成增量表達式為 x+ 。10假定p所指對象的值為36,p+l所指對象的值為49,則*+p的值為 49 。11假定要訪問一
7、個結(jié)構(gòu)對象x中的由a指針成員所指向的對象,則表示方法為 *(xa) 。12對一個類中的數(shù)據(jù)成員的初始化可以通過構(gòu)造函數(shù)中的 初始化表 實現(xiàn),也可以通過構(gòu)造函數(shù)中的 函數(shù)體 實現(xiàn)。13在C+程序中,語句之間必須用 ; 分隔。14在C+程序中, 運算符優(yōu)先級最低。15在C+語言中,在IBM PC機環(huán)境下,double型數(shù)據(jù)占 8 字節(jié)。16若k 為int型變量,則下列語句的輸出為 16 。k=017;cout<<+k;17表達式 b*b-4*a*c>0 是判斷一元二次方式ax2+bx+c=0有實根的表達式。18表達式(b=10)&&(c=0)的值為 0 。19已知
8、a的ASCII的十進制代碼為97,則表達式10+15.2-27*(a-b)的值為 52.2 。20在C+語言中,& 作為雙目運算符時表示的是 按位與 ,而作為單目運算時表示的是 引用 。21一個函數(shù)由函數(shù) 名 和函數(shù) 體 兩部分構(gòu)成。22C+在執(zhí)行過程中不檢查數(shù)組是否 越界 。23C+語言規(guī)定,調(diào)用一個函數(shù)時,實參數(shù)變量與形參數(shù)變量之間的數(shù)據(jù)傳遞是 。24指針變量的指針是 地址 。25結(jié)構(gòu)體變量中的成員的引用一般形式:結(jié)構(gòu)變量名成員名 。26寫出滿足A>B則把A+B賦給M的if語句 if(A>B) M=A+B 。27寫出指向int型變量的指針變量p的一個定義語句: int
9、*p 。三、給出下列程序運行后的輸出結(jié)果1#include<iostream.h> void SB(char ch) switch(ch) case 'A': case 'a': cout<<"well !" break; case 'B': case 'b': cout<<"good !" break; case 'C': case 'c': cout<<"pass ! " break; d
10、efault: cout<<"bad! " break; cout<<endl; void main() char a6 ="Abcaf" for(int i=0; ai; i+) SB(ai);答案:well !good !pass !well !bad!2#include<iostream.h> void main() int a10= 36,25,48,14,55,40,72,40,86,27; int b1, b2; b1 = b2 = a0; for(int i= 1;i<10;i+) if(ai>
11、;b1) if(b1>b2) b2=b1; b1 = ai; cout<<b1<<' '<<b2<<endl; 答案:86 723#include<iomanip.h> void main() int a8= 3,5,7,9,11,13,15,17; int *p=a; for(int i=0;i<8;i+) *p+=10; cout<<setw(5)<< *p+; if (i+1) %3=0) cout<<endl; 答案:13 15 2719 21 2325 274.
12、 #include<iomanip.h> void LE(int* a, int* b) int x=*a; *a=*b; *b=x; cout<<*a<<' '<<*b<<endl; void main() int x=10, y=25; LE(&x,&y); cout<<x<<' '<<y<<endl; 答案:25 1025 105. #include<iostream.h> class A int a,b; public:
13、 A() a=b=0; A(int aa, int bb) a=aa; b=bb; cout<<a<<' '<<b<<endl; ; void main() A x,y(2,3),z(4,5); 答案:(下面是四個數(shù),中間有空格)2 34 56#include<iostream.h>void main()int m=3,x=4,y=4,z=7;m=(m<x)?x+: m;m=(m<y)?y+: m;m=(m<z)?z+: m;cout>>“m=”>>m>>endl&
14、gt;>”x=”>>x>>endl>>”y=”>>y>>endl>>”z=”>>z;程序運行后的輸出結(jié)果為:答案:m=7x=5y=4z=87#include<iostream.h>void sort(int x,int y,int z) int t;if (x>y)t=x;x=y;y=t;if(x>z)t=x;x=z;z=t;if(y>z)t=y;y=z;z=t;cout>>“x=”>>x>> >>”y=”>>y&g
15、t;> >>”z=”>>z;void main() int a,b,c;cin>>a>>b>>c;cout>>“a=”>>a>> >>”b=”>>b>> >>”c=”>>c;sort(a,b,c);cout>>“a=”>>a>> >>”b=”>>b>> >>”c=”>>c;假設輸入為:10 6 8<CR>則程序運行后的輸出結(jié)果為
16、:參考答案:a=10 b=6 c=8x=6 y=8 z=10a=10 b=6 c=88. #include<iostream.h>void prn str(char *str,int m,int n)int i;for (i=1;i<m;i+)cout>>“*”;str+;for (i=1;(i<=n)&&(*str);i+)court>>*str+;while(*str)cout>>“*”;str+;cout>>endl;void main() char *p=“information”;prn str(
17、p,3,4);程序運行后的輸出結(jié)果為:答案: *form*四、寫出下列每個函數(shù)的功能1.int Count(double a, int n) double m=0; int i;for(i=0;i<n;i+) m+=ai; m=m/n; int c=0;for(i=0;i<n;i+) if(ai>=m) c+;return c; 答案:計算并返回參數(shù)數(shù)組中大于等于參數(shù)數(shù)組中所有元素平均值的元素個數(shù)2.long fact(long n)if (n<=1L) return 1L;return n*fact(n-1L);答案:通過函數(shù)遞歸調(diào)用,計算并返回參數(shù)n的階乘 3. #
18、include<iostream.h> void WA(int a, int n) for(int i=0;i<n-1;i+) int k=i; for(int j=i+1;j<n;j+) if(aj<ak) k=j; int x=ai; ai=ak; ak=x; 答案:對參數(shù)數(shù)組中的元素進行升序排序 4#include<iomanip.h> #include<fstream.h> void JB(char* fname) /可把以fname所指字符串作為文件標識符的文件稱為fname文件, /假定該文件中保存著一批字符串,每個字符串的長度
19、均小于20。 ifstream fin(fname); char a20; int i=0; while(fin>>a) cout<<a<<endl; i+; fin.close(); cout<<"i="<<i<<endl; 答案:依次把參數(shù)fname所指的文件中字符輸入到字符串數(shù)組a中,并輸出文件中字符個數(shù)五、編程題1設計一程序,它輸入一個整數(shù),判斷它是否是整數(shù)序列32,52,31,86,3,44,11,7,55,63中的一個;若是,顯示該整數(shù)在序列中的序號(注:最小序號是1),否則顯示0。答案:#
20、include<iostream.h> int getno(int val) int a=32,52,31,86,3,44,11,7,55,63; for(int i=0;i<10;i+) if(val=ai) return(i+1); return(0); void main() int val; cin>>val; cout<<getno(val);2.編寫一個程序,統(tǒng)計輸入的一行字符中數(shù)字、空格及其它字符分別有多少個。答案:#include<iostream.h>void main() int i,eng=0,numb=0,blan=
21、0,others=0; char a100; cin.getline(a,100); for(i=0;ai;i+) if(ai<57&&ai>48) numb+; else if(ai=32) blan+; else if(ai>65&&ai<90)|(ai>97&&ai<97+25) eng+; else others+; cout<<"eng="<<eng<<endl<<"numb="<<numb<&l
22、t;endl;cout<<"blan="<<blan<<endl<<"others="<<others<<endl; 3.有8個學生,每個學生四門課程的成績存放在一個8行5列的二維數(shù)組的0到7行的1到4列中,編寫一個函數(shù)實現(xiàn):計算每個學生四門課程的總成績,并存放在該學生所在行的第0列中。答案:#include<iostream.h>void main() int i,j;int a85=0;for(i=0;i<8;i+)for(j=1;j<5;j+)cin&g
23、t;>aij; /輸入學生成績for(i=0;i<8;i+)for(j=1;j<5;j+)ai0+=aij; /求學生四門課程總成績請您刪除一下內(nèi)容,O(_)O謝謝!2015年中央電大期末復習考試小抄大全,電大期末考試必備小抄,電大考試必過小抄Many people have the same mixed feelings when planning a trip during Golden Week. With heaps of time, the seven-day Chinese請您刪除一下內(nèi)容,O(_)O謝謝!National Day holiday could be
24、 the best occasion to enjoy a destination. However, it can also be the easiest way to ruin how you feel about a place and you may become more fatigued after the holiday, due to battling the large crowds. During peak season, a dream about a place can turn to nightmare without careful planning, especi
25、ally if you travel with children and older people. As most Chinese people will take the holiday to visit domestic tourist destinations, crowds and busy traffic are inevitable at most places. Also to be expected are increasing transport and accommodation prices, with the possibility that there will b
26、e no rooms available. It is also common that you' ll wait in the line for one hour to get a ticket, and another two hours at the site, to only see a tiny bit of the place due to the crowds. Last year, 428 million tourists traveled in China over the week-long holiday in October. Traveli
27、ng during this period is a matter that needs thorough preparation. If you are short on time to plan the upcoming "Golden Week" it may not be a bad idea to avoid some of the most crowded places for now. There is always a place so fascinating that everyone yearns for. Arxan is a place like t
28、his. The beauty of Arxan is everlasting regardless of the changing of four seasons. Bestowed by nature, its spectacular seasonal landscape and mountains are just beyond word. Arxan is a crucial destination for the recommended travelling route, "China Inner Mongolia Arxan Hailar Manzhouli".
29、 It is also the joint of the four prairies across the Sino-Mongolian border, where people gravitate towards the exotic atmosphere mixed with Chinese, Russian, and Mongolia elements. As a historic site for the Yitian Battle, Arxan still embodies the spirit of Genghis Khan. Walking into Arxan, you wil
30、l be amazed by a kaleidoscope of gorgeous colors all the year round - the Spring azaleas blooming red in the snow, the Summer sea wavering blue in the breeze, the Autumn leaves painted in yellow covering volcanic traces, and the Winter woods shining white on the vast alpine snowscape. Hinggan League
31、 Arxan city is situated in the far eastern area of Inner Mongolia Autonomous Region. Its full name "Haren Arxan" means "hot holy water" in the Mongolian language. Arxan is a tourism city in the northern frontier with a blend of large forest, grand prairies, vast snowfield, heaven
32、 lake cluster, thermium, as well as volcanic cluster. It is a rare and unique ecotourism base filled with healthy sunshine, clean air and unspoiled green. Nestled close to the country's largest virgin forest, and known for its spring and ecological environment, Arxan is marveled at by many
33、 tourists as the purest land on earth. You cannot miss out the Autumn of Arxan. It is definitely the best with brightly-colored scenery full of emotions. Autumn in the northern part of the country comes earlier than the South. A September rain followed by the footprints of Autumn brings
34、more colors to the once emerald green mountain and blooming grassland. Shutterbugs flock to see for themselves the marvel of splendid colors around the mountains and waters, many of whom have travel a long distance and even camp here only to capture a moment of the nature wonder. The sil
35、ver birch turns golden, while the larch is still proudly green. You will find yourself drowned in the intoxicating red of the wild fruits as well as the glamour of flowers in full blown. And your heart will be lingering on the woods as it's time for the wild fruits to ripe. The picturesque Arxan
36、 in Autumn is indeed a fairyland only exists in a dream that satisfies all your fantasies. If it rains heavily on Saturday night, some elderly Chinese will say it is because Zhinu, or the Weaving Maid, is crying on the day she met her husband Niulang, or the Cowherd, on the Milky Way. Most Chin
37、ese remember being told this romantic tragedy when they were children on Qixi, or the Seventh Night Festival, which falls on the seventh day of the seventh lunar month, which is usually in early August. This year it falls on Saturday, August 2. Folklore Story As the story goes, once there was a cowh
38、erd, Niulang, who lived with his elder brother and sister-in-law. But she disliked and abused him, and the boy was forced to leave home with only an old cow for company. The cow, however, was a former god who had violated imperial rules and was sent to earth in bovine form. One day the cow led Niula
39、ng to a lake where fairies took a bath on earth. Among them was Zhinu, the most beautiful fairy and a skilled seamstress. The two fell in love at first sight and were soon married. They had a son and daughter and their happy life was held up as an example for hundreds of years in China. Yet in the e
40、yes of the Jade Emperor, the Supreme Deity in Taoism, marriage between a mortal and fairy was strictly forbidden. He ordered the heaven troop to catch Zhinu back. Niulang grew desperate when he discovered Zhinu had been taken back to heaven. Driven by Niulang's misery, the cow told him to turn i
41、ts hide into a pair of shoes after it died. The magic shoes whisked Niulang, who carried his two children in baskets strung from a shoulder pole, off on a chase after the empress. The pursuit enraged the empress, who took her hairpin and slashed it across the sky creating the Milky Way which separat
42、ed husband from wife. But all was not lost as magpies, moved by their love and devotion, formed a bridge across the Milky Way to reunite the family. Even the Jade Emperor was touched, and allowed Niulang and Zhinu to meet once a year on the seventh night of the seventh month. This is how Qixi came t
43、o be. The festival can be traced back to the Han Dynasty (206 BC-AD 220). Traditionally, people would look up at the sky and find a bright star in the constellation Aquila as well as the star Vega, which are identified as Niulang and Zhinu. The two stars shine on opposite sides of the Milky Way. Cus
44、toms In bygone days, Qixi was not only a special day for lovers, but also for girls. It is also known as the "Begging for Skills Festival" or "Daughters' Festival." In this day, girls will throw a sewing needle into a bowl full of water on the night of Qixi as a test of embro
45、idery skills. If the needle floats on top of the water instead of sinking, it proves the girl is a skilled embroiders. Single women also pray for finding a good husband in the future. And the newly married women pray to become pregnant quickly. Tradition transformed The love story of Niulang and Zhi
46、nu, and the Qixi Festival have been handed down for generations. Yet these ancient traditions and customs are slowly dying out. Many modern Chinese, particularly youngsters, seem to know more about St Valentine's Day on February 14, characterized by bouquets of roses, chocolates and romantic can
47、dlelight dinners, than they do about their home-grown day for lovers. Even Qixi is nowadays referred to as the "Chinese Valentine's Day." More and more young Chinese people begin to celebrate this day in a very similar way as that in western countries. Fewer people than ever will gaze
48、at the heavens on Saturday to pick out the two stars shining bright on either side of the Milky Way, that is, if people even know on which day Qixi falls. There are ready reminders dotted about, in the form of big ads saying "Sales on Chinese Valentine's Day!" in shops, hotels and rest
49、aurants. But few young women will mark the festival with their boyfriends, or take part in traditional activities to pray for cleverness. A large-scale of exhibition on the Silk Road opened to the public in the National Museum on Thursday. The exhibition displays more than 400 treasures from Shaanxi
50、 province, Gansu province and 14 other regions. It is largest scale exhibition that shows the history of the Silk Road in recent years. As APEC is going on in Beijing, the exhibit aims to show the world this brilliant section of history. The Silk Road is a series of trade and cultural tran
51、smission routes that were central to cultural interaction through regions of the Asian continent. It connected the West and East by linking traders, merchants, pilgrims, monks, soldiers, nomads, and urban dwellers from China and India to the Mediterranean Sea during various periods of time. I met my
52、 dear hubby in 2009 the second year I was in my school and it was the first year when he came here. We became colleagues. And there was nothing special happening during that year. He was just a kind and humble brother graduated from the same college as me. But we did not know each other till he beca
53、me my colleague and his office desk was just in front of me. There was only a glass between us. So actually we could see each other when we both look up. But it is not the main reason that really draws us close. How we become close to each other was something seems quite natural. We went out to play
54、 badminton with other colleagues and we sometimes chatted for a while. He is a man of few words but somehow sometimes will say something really humorous. Then one day, to my great surprise, I found a pot of beautiful flower on my desk. It was just the flower I had talked about with my colleague the
55、other day, and I thought it was her who put the flower there. But the truth is not. It was the humble guy sitting in front of me. He just simply said ,”well, I caught sight of this flower and thought that its beautiful and you may like it”. I wonder why I was moved because of these simple words and
56、present. Maybe it is the sincerity and the true self that impress me. I thanked him and some colleagues walked past my desk would appreciate the beautiful flower and they noticed that something romance happened there. Then later on, there were some little surprises once in a while. Once, there was something wrong with my drawer and I had complained about it unconsciously. And he fixed it for me. Then the other day, he placed several pink diamond roses beside the flower with a piece of paper saying” I love you more than I c
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 隔斷合同范本格式
- 2025至2030年中國流延膜生產(chǎn)線數(shù)據(jù)監(jiān)測研究報告
- 互動傳媒承包合同
- 未來教室現(xiàn)代教育技術的實踐與思考
- 臨時工培訓補貼協(xié)議
- 商業(yè)打印機維護合同
- 2025至2030年中國永磁同步齒輪減速電機數(shù)據(jù)監(jiān)測研究報告
- 各類商業(yè)活動的預算與造價咨詢合同
- 縣域經(jīng)濟發(fā)展接送協(xié)議
- 借款合同自動展期合同范本
- 中華護理學會團體標準測試題庫含答案
- 防暴隊形演練和講解
- 2024年醫(yī)療器械經(jīng)營質(zhì)量管理規(guī)范培訓課件
- 廣電和通信設備電子裝接工(高級工)理論考試復習題庫(含答案)
- 2024年河南住戶調(diào)查業(yè)務題庫
- 中小企業(yè)(民營企業(yè))ESG星級評價
- 電氣工程及其自動化職業(yè)規(guī)劃課件
- 天車安全操作培訓教材
- 《籃球運球》教案(共四篇)
- 國企關于違反“三重一大”決策制度責任追究辦法
- CRF病例報告表模板
評論
0/150
提交評論