![電大形成性考核冊c第三次作業(yè)及答案_第1頁](http://file1.renrendoc.com/fileroot_temp2/2021-2/1/e20b036d-40e1-417a-a00b-6d823fa639cd/e20b036d-40e1-417a-a00b-6d823fa639cd1.gif)
![電大形成性考核冊c第三次作業(yè)及答案_第2頁](http://file1.renrendoc.com/fileroot_temp2/2021-2/1/e20b036d-40e1-417a-a00b-6d823fa639cd/e20b036d-40e1-417a-a00b-6d823fa639cd2.gif)
![電大形成性考核冊c第三次作業(yè)及答案_第3頁](http://file1.renrendoc.com/fileroot_temp2/2021-2/1/e20b036d-40e1-417a-a00b-6d823fa639cd/e20b036d-40e1-417a-a00b-6d823fa639cd3.gif)
![電大形成性考核冊c第三次作業(yè)及答案_第4頁](http://file1.renrendoc.com/fileroot_temp2/2021-2/1/e20b036d-40e1-417a-a00b-6d823fa639cd/e20b036d-40e1-417a-a00b-6d823fa639cd4.gif)
![電大形成性考核冊c第三次作業(yè)及答案_第5頁](http://file1.renrendoc.com/fileroot_temp2/2021-2/1/e20b036d-40e1-417a-a00b-6d823fa639cd/e20b036d-40e1-417a-a00b-6d823fa639cd5.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、計算機應用專業(yè)“C+語言程序設計”課程作業(yè) 第三次作業(yè) 一、填空題 1假定p所指對象的值為28,p+1所指對象的值為62,則* p + +的值為 28 。 2假定p所指對象的值為28,p+1所指對象的值為62,則* + + p的值為 62 。 3假定p所指對象的值為25,p+1所指對象的值為50,則執(zhí)行“(*p)+ +;”語句后,p所指對象的值為 26 。 4假定p所指對象的值為25,p+1所指對象的值為50,則執(zhí)行“*(p+ +);”語句后,p所指對象的值為 50 。 5假定a是一個指針數(shù)組,則a+i所指對象的地址比a地址大 未知 字節(jié)。 6假定a是一個一維數(shù)組,則ai的指針訪問方式為 *(
2、a+i) 。 7假定a是一個二維數(shù)組,則ai j的指針訪問方式為 *(*(a+i)+j) 。 8假定a是一個一維數(shù)組,則ai對應的存儲地址(以字節(jié)為單位)為 (char *)a+i*sizeof(a0) 。 9假定一個二維數(shù)組為aM N,則ai j對應的存儲地址(以字節(jié)為單位)為 (char *)a+(i*N+j)*sizeof(a00) 。 10假定一個二維數(shù)組aM N,則ai的地址值(以字節(jié)為單位)為 (char *)a+i*N*sizeof(a00) 。 11假定p是一個指向float型數(shù)據(jù)的指針,則p+1所指數(shù)據(jù)的地址比p所指數(shù)據(jù)的地址大 4 字節(jié)。 12假定a為一個字符數(shù)組名,則元素
3、a8的字節(jié)地址為 8 。 13假定a為一個整型數(shù)組名,則元素a4的字節(jié)地址為 16 。 14假定一個結構類型的定義為“struct Aint a,b;short c;A*d;”,則該類型的大小為 14 字節(jié)。 15假定一個結構類型的定義為“struct Bint a8;char* b;”,則該類型的大小為 36 字節(jié)。 16假定一個結構類型的定義為“struct Dint a;unionint b;double c;D*d3;”,則該類型的大小為 24 字節(jié)。 17假定要動態(tài)分配一個類型為Worker的具有n個元素的數(shù)組,并由r指向這個動態(tài)數(shù)組,則使用的語句為 r=new Workern; 。
4、 18假定要訪問一個結構x中的由a指針成員所指向的對象,則表示方法為 *(x.a) 。 19假定要訪問一個結構指針p所指對象中的b指針成員所指的對象,則表示方法為 *(p-b) 。 二、給出下列程序運行后的輸出結果 以下結果中空格以表示 1include void main() ;7,9,11,13,3,8,15,17int a8=int *p = a; for(int i =0;i8;i + +) coutsetw(5) * p + +; if(i +1)%4 = =0)coutendl; 791113 381517 2include void main() int a5=3,6,15,7,
5、20; int *p = a; for(int i = 0;i5;i + +) coutsetw(5) * p + +; coutendl; for(i =0;i5;i + +) coutsetw(5) * p; coutendl; 3615720 2071563 3include void main() int a8 =4,8,12,16,20,24,28,32; int *p = a; do cout *p ; p + =3; while(pa+8); coutendl; 4 16 28 4include void main() int x =20,y =40, * p; p =&x;co
6、ut * p ; * p= x +10; p =&y;cout * pendl; * p = y +20;cout x y endl; 20 40 30 60 5include )int * a,int n(int LAint s = 0; for(int i =0;in;i + +) s + = ai; return s; void main() int a =5,10,15,20,25,30; int b =LA(a,5); int c =LA(a+3,2); cout b c b +2 * cendl; 75 45 165 6include void LC(int a,int b) in
7、t x = a; a = b;b = x; cout a b endl; void main() int x =15,y =36; LC(x,y);cout x y endl; 36 15 15 36 7include void LF(int & x, int y) x = x + y; y = x + y; cout”x =” x ”,y =” y endl; void main() int x =5,y =8; cout”x =” x ”,y =” y endl; LF(x,y); cout”x =” x ”,y =” y endl; x=5,y=8 x=13,y=21 x=13,y=8
8、8include void LG(int * & a, int & m) a = new intm; int * p = a; )i + +;im;int i = 0(for* p + + =2 * i +1; void main() int * p, n =5; LG(p,n); for(int i = 0;in;i + +) cout pi ; coutendl; delete p; 1 3 5 7 9 9include void LH(int * a, int n) int * p = a + n1; whlie(ap) int x = * a; * a = * p; * p = x;
9、a + +;p ; void main() int * d = new int5; int i; for(i = 0;i5;i + +) di=2 * i +3; coutsetw(5)di ; coutendl; LH(d,5); for(i = 0;i5;i + +) coutsetw(5)di ; coutendl; delete d; 357911 119753 10include struct Worker char name15;/ /姓名 int age;/ /年齡 float pay;/ /工資 ;void main() Worker x =”weirong”,55,640;
10、Worker y, * p; y = x;p =&x; cout y. name y. age y. payendl; coutname age+5 pay10endl; weirong 55 640 weirong 60 630 11include include struct Worker char name15;/ /姓名 int age;/ /年齡 float pay;/ /工資 ; void main() Worker x; char * t =”liouting”; int d =46;float f =725; strcpy(x. name, t); x. age = d;x.
11、pay = f; cout x. name x. age x. payendl; liouting 46 725 三、寫出下列每個函數(shù)的功能 1include void LI(int n) int * a = new intn, * p = a + n; for(int i =0;i ai; for(i = n1;i =0;i )cout *( p) ; cout n; delete a; 輸入n個數(shù)并以相反的順序顯示出來。 2include void LK(int a , int n, int * & b, int& m) float s =0;int i; for(i =0;in;i +
12、+) s + = ai; s/= n; m = 0; for(i =0;i = s(ifb = new intm; int * p = b; for(i =0;i = s)* p + + = ai; 將數(shù)組a中大于平均數(shù)的元素存放到動態(tài)申請的數(shù)組b中,數(shù)組b的大小由m返回。 3/ /struct Worker / / char name15;/ /姓名 / / int age;/ /年齡 / / float pay;/ /工資 / /; istream & operator(istream& istr,Worker& x) cout”請輸入一個職工記錄:姓名、年齡、工資” x. name x. age x. pay; return istr; 重載istream的操作符以輸入Worker結構對象。 4/ / struct StrNode / / char name15;/ /字符串域 / / StrNode * next;/ /指針域 / /; void QB(StrNode * & f, int n) if(n = = 0)f =NULL;return; f =new StrNode; cinfname; StrNode * p = f; whlie
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 未來電商模式探索與展望
- 現(xiàn)代企業(yè)財務管理的倫理與責任
- 生產(chǎn)管理策略與工藝優(yōu)化技術
- 災害預防教育學校防災減災的必由之路
- 環(huán)保節(jié)能建筑的設計與實施案例分享
- 2024年重陽節(jié)活動策劃方案-11
- 現(xiàn)代物流與科技融合的商業(yè)模式
- 國慶節(jié)房地產(chǎn)促銷方案
- 2024年五年級英語上冊 Unit 6 In a nature park Part A 第三課時說課稿 人教PEP
- 2024-2025學年新教材高中語文 第二單元 5 雷雨(節(jié)選)(1)說課稿 部編版必修下冊
- 2025年1月浙江省高考政治試卷(含答案)
- 教體局校車安全管理培訓
- 湖北省十堰市城區(qū)2024-2025學年九年級上學期期末質量檢測綜合物理試題(含答案)
- 導播理論知識培訓班課件
- 空氣能安裝合同
- 中國人婚戀狀況調查報告公布
- 早產(chǎn)兒視網(wǎng)膜病變
- GB 10665-1997碳化鈣(電石)
- 《中小學教育懲戒規(guī)則》重點內容學習PPT課件(帶內容)
- 板帶生產(chǎn)工藝5(熱連軋帶鋼生產(chǎn))課件
- 2022年同等學力英語考試真題及詳解
評論
0/150
提交評論