




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、double fun1(double x) /*/ double f; f=(1+sin(x)+exp(x)/(1+x); return f; /*/ void main() clrscr(); printf(un1 = %n, fun1); printf(un1 = %n, fun1); printf(un1 = %n, fun1); 12打開考生文件夾中的,完成其中的函數(shù)fun2(int a ,int n,int b ,int c ),實(shí)現(xiàn): 1)將數(shù)組a中大于20的元素依次存放在數(shù)組b中; 2)將數(shù)組b中的元素按照從小到大的順序依次存放到數(shù)組c中; 3)函數(shù)返回?cái)?shù)組b中的元素個(gè)數(shù)。 #i
2、nclude #include #include #include int fun2(int a,int n,int b,int c) /*/ int nb=0; int i,j=0,temp; for(i=0;i-20) bj=ai;nb+;j+; for(i=0;inb;i+) ci=bi; for(i=0;inb-1;i+) for(j=0;jcj+1) temp=cj; cj=cj+1; cj+1=temp; return nb; /*/ void main() int n = 10, i, nb; int aa10 = 12, -10, -31, -18, -15, 50, 17,
3、15, -20, 20; int bb10, cc10; clrscr(); printf(There are - elements in aa.n, n); printf(They are: ); for(i=0; in; i+) printf(m, aai); printf(); nb = fun2(aa, n, bb, cc); printf(Elements in bb are: ); for (i=0; inb; i+) printf(m, bbi); printf(); printf(Elements in cc are: ); for(i=0; inb; i+) printf(m
4、, cci); printf(); printf(There are - elements in bb.n, nb); 21打開考生文件夾中的,完成其中的函數(shù)fun1,該函數(shù)的數(shù)學(xué)表達(dá)式使: 例如:fun1=3. 582 fun1= fun= #include #include double fun1(double x) /*/ double f; f=(exp(x) +fabs(x-6) / (x+; return f; /*/ void main() clrscr(); printf(un1 = %n, fun1); printf(un1 = %n, fun1); printf(un1 =
5、 %n, fun1); 22打開考生文件夾中的,完成其中的函數(shù)fun2(char a ,char b ,char c ),實(shí)現(xiàn):將三個(gè)字符串a(chǎn)、b、c從小到大排序后輸出。 注意:字符串比較函數(shù)為strcmp(str1,str2), 字符串賦值函數(shù)為strcpy(str1,str2)。 #include #include #include #include void fun2(char a,char b,char c) /* */ char temp15; if(strcmp(a,b)0) strcpy(temp,a);strcpy(a,b); strcpy(b,temp); if(strcmp
6、(a,c)0) strcpy(temp,a);strcpy(a,c); strcpy(c,temp); if(strcmp(b,c)0) strcpy(temp,b);strcpy(b,c); strcpy(c,temp); /*/ void main() char str115=Fuzhou,str215=Fujian,str315=China; clrscr(); fun2(str1,str2,str3); printf(The ordered strings is : %s, %s, %sn,str1,str2,str3); getch(); 31打開完成其中的函數(shù)fun1,該函數(shù)的數(shù)學(xué)
7、表達(dá)式是: 當(dāng)x3時(shí) 例如: fun1= fun1= fun1= #include #include double fun1(double x) /*/ double f; if(x3) f=; else if(x=3) f=10; else f=2*x+1; return f; /*/ void main() clrscr(); printf(un1 = %n, fun1); printf(un1 = %n, fun1); printf(un1 = %n, fun1); 32打開完成其中的函數(shù)fun(char *s),使程序?qū)崿F(xiàn)統(tǒng)計(jì)輸入字符串中空格的個(gè)數(shù)。 #include int fun(
8、char *s) /*/ int i,n=0; for(i=0 ; si!=0;i+) if(si= ) n+; return n; /*/ void main() char str255; gets(str); printf(%dn,fun(str); 41打開程序,完成其中的f( )函數(shù),使其計(jì)算: 如 輸入:12 輸出:f= 輸入: 輸出:f= 輸入: 輸出:f= #include #include double f(float x) /*/ double f; if(x=0) f=0; else f=(fabs(x)+/(sin(x)+2); return f; /*/ void ma
9、in() float x; double y; printf(Please input a number: n); scanf(%f,&x); y = f(x); printf(%.3f)=%.3fn,x,y); getch(); 42打開程序,完成其中的fun( )函數(shù),使函數(shù)打印出Fibonacci數(shù)列的前20個(gè)數(shù)。該數(shù)列(1,1,2,3,5,8,13,)的第1、第2個(gè)數(shù)為1,從第3個(gè)數(shù)開始每個(gè)數(shù)等于前2個(gè)數(shù)之和。 #include #include void fun(int a,int m) /*/ int i; a0=a1=1; for(i=2;i20;i+) ai=ai-1+ai-2
10、; /*/ void main() int a20,i; fun(a,20); for(i=0; i20; i+) printf(%d ,ai); printf(); getch(); 51打開程序,完成其中的f( )函數(shù),使其計(jì)算: 如 輸入: 輸出:f= 輸入: 輸出:f= 輸入:780 輸出:f= #include #include double f(float x) /*/ double f; if(fabs(x)700) f=(sqrt+fabs(x)/(cos(x)+; else f=; return f; /*/ void main() float x; double y; pr
11、intf(Please input a number: n); scanf(%f,&x); y = f(x); printf(%0.2f)=%0.2fn,x,y); getch(); 52打開程序,完成其中的fun( )函數(shù),使其判斷一個(gè)矩陣是否為對(duì)稱矩陣,若矩陣對(duì)稱返回1,不對(duì)稱返回0。說明:矩陣a使一個(gè)二維數(shù)組,若其中的第k行第j列的元素與第j行第k列的元素相同,則稱其為對(duì)稱矩陣,否則為非對(duì)稱矩陣。 如 輸入:6 3 12 如 輸入:6 9 12 3 18 8 3 18 8 12 8 7 34 8 22 輸出:Yes 輸出:No #include #include int fun(int
12、a3,int m) /*/ int b=1; int i,j; for(i=0;im;i+) for(j=0;jm;j+) if(aij!=aji) b=0;break; if(b=0) break; return b; /*/ void main() int a33,i,j; int b; fun(a,20); for(i=0; i3; i+) for(j=0; j3; j+) scanf(%d,&aij); b = fun(a,3); if( b = 1 ) printf(Yesn); else printf(Non); getch(); 61 打開程序,完成其中的f( )函數(shù),使其計(jì)算:
13、 如:輸入: 輸出:f= 輸入: 輸出:f= 輸入:725 輸出:f= #include #include double f(float x) /*/ double f; if(fabs(x)300) f=pow(x,3) /log10(fabs(x)+; else f=; return f; /*/ void main() float x; double y; printf(Please input a number: n); scanf(%f,&x); y = f(x); printf(%0.2f)=%0.2fn,x,y); getch(); 62 打開程序,完成其中的fun( )函數(shù),使其實(shí)現(xiàn)四則運(yùn)算的功能。 如:輸入: 輸出:+= *= = #include #include float fun(float a,char flag,float b) /*/ float f; switch(flag) case +: f=a+b; break; case -: f=a-b; break; case *: f=a*b; break; case /: f=a/b; break; return f; /*/ void main() float a,b; pri
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年鏈家房屋買賣定金支付及退還標(biāo)準(zhǔn)協(xié)議
- 二零二五年度住房租賃補(bǔ)貼擔(dān)保服務(wù)合同
- 二零二五年度蘇州市教育機(jī)構(gòu)用工企業(yè)勞動(dòng)合同書
- 二零二五年度云計(jì)算資源合作共享合同
- 2025年度電子商務(wù)平臺(tái)招防范合同法律風(fēng)險(xiǎn)合作協(xié)議
- 2025年度涂料班組涂料行業(yè)市場(chǎng)分析咨詢合同
- 二零二五年度特色日租房短租體驗(yàn)協(xié)議書
- 二零二五年度貸款居間代理及金融科技創(chuàng)新應(yīng)用合同
- 2025年度高端合同事務(wù)律師服務(wù)合同
- 2025年度智慧交通項(xiàng)目提前終止合同及交通設(shè)施移交協(xié)議
- 2024陸上風(fēng)電場(chǎng)改造拆除與循環(huán)利用設(shè)計(jì)導(dǎo)則
- 《消費(fèi)者權(quán)益與法律保護(hù)》課程培訓(xùn)教案課件
- 新概念英語第一冊(cè)語法練習(xí)
- 無人機(jī)法律法規(guī)與安全飛行 第2版 課件 8-2 -無人機(jī)人員的法律責(zé)任
- 產(chǎn)品外觀檢驗(yàn)標(biāo)準(zhǔn)通用
- 《建筑基坑工程監(jiān)測(cè)技術(shù)標(biāo)準(zhǔn)》(50497-2019)
- 2023年江蘇省泰州市高職單招數(shù)學(xué)摸底卷五(含答案)
- 質(zhì)量管理體系中英文縮寫與其解釋
- 歷史文獻(xiàn)學(xué)之文獻(xiàn)??苯o09歷史開第二章
- 中國(guó)教育行業(yè)調(diào)查報(bào)告-《中國(guó)教育行業(yè)白皮書》
- 鑄造廠重要危險(xiǎn)源清單
評(píng)論
0/150
提交評(píng)論