




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、第六章 程序設(shè)計編程題1. 求園的面積(要求判斷半徑是否合理)cleainpu r= to rif r0 s=3.14*r*r ?selse ?半徑錯誤!endif2. 求分段函數(shù)y的值y=2x5 x0x x=0| x | x0 y=2*x+5else if x=0y=x elsey=abs(x) endifendif?y3. 輸入一個百分制成績判斷其等級(優(yōu)/良/中/及格/不及格)cleainpu cj= to cjdo case case cj=90?優(yōu) case cj=80?良 case cj=70?中 case cj=60?及格 orth?不及格endcase4. 輸入若干個(個數(shù)不定
2、)百分制成績判斷其等級(優(yōu)/良/中/及格/不及格)cleainpu 請輸入處理幾個人的成績: to nfor i=1 to ninpu cj= to cjdo case case cj=90?優(yōu) case cj=80?良 case cj=70?中 case cj=60?及格 orth?不及格endcaseendfor5. 求s1+2+3. . . . . .+100cleas=0for i=1 to 100 s=s+iendfor?s 6. 求s123. . . . . .100cleap=1for i=1 to 100 p=p*iendfor?p7. 求s1+3+5. . . . .+99c
3、leas=0for i=1 to 99 step 2 s=s+iendfor?s8. 求s12+34. . . . . .100cleas=0for i=1 to 100 s=s+(-1)(i+1)*iendfor?s9. 求s1+1/2+2/3+3/5. . . . . .前10項之和cleas=0a=1b=1for i=1 to 10 s=s+a/b t=a a=b b=t+bendfor?s10. 求s1!+2!+3!. . . . . .+10!cleas=0p=1for i=1 to 10p=p*i s=s+p endfor?s11. 對學(xué)生表中所有入學(xué)成績650分的學(xué)生免去貸款cl
4、eause 學(xué)生scan for入學(xué)成績=650 .and. 貸款否=.t. repl貸款否 with .f.endscanuse* * * * * * * * * * * * * * * * * * * * *12. 輸出圖形cleafor i=1 to 4 for j=1 to i?* endfor ?endforcleafor i=1 to 4 for j=1 to 4-i? &有一個空格 endfor for j=1 to 2*i-1?* endfor ?endforcleafor i=1 to 4 for j=1 to 4-i? &有一個空格 endfor for j=1 to i?
5、* endfor ?endfor13. 判斷一個整數(shù)是否素數(shù)cleainpu x= to xfor i=2 to x-1 if mod(x,i)0loop elseexitendifendforif ix-1 ?x,是素數(shù)else ?x,不是素數(shù)endif14. 判斷十個整數(shù)是否素數(shù)cleafor j=1 to 10inpu x= to xfor i=2 to x-1 if mod(x,i)0loop elseexitendifendforif ix-1 ?x,是素數(shù)else ?x,不是素數(shù)endifendfor15. 找出兩個數(shù)的大數(shù)和小數(shù)cleainpu x= to xinpu y to
6、yif xy ?x,大,y,小else ?y,大,x,小endif16. 找出三個數(shù)的最大數(shù)和最小數(shù)cleainpu x= to xinpu y to yinpu z to zif xy t=xx=yy=telse if xz t=xx=zz=t endifendifif yz t=yy=zz=tendif?x,是最大數(shù),z,是最小數(shù)17. 找出十個數(shù)的最大數(shù)和最小數(shù)cleadime a(10)for i=1 to 10 inpu to a(i)endformax=a(1)min=a(1)for i=2 to 10 if maxa(i) min=a(i)endif endifendfor?ma
7、x,min18. 找出23矩陣中的最大數(shù)和最小數(shù)cleadime a(2,3)for i=1 to 2 for j=1 to 3input a(+str(i,2)+,+str(j,2)+)= to a(i,j) endforendformax=a(1,1)min=a(1,1)for i=1 to 2 for j=1 to 3if max a(i,j) min= a(i,j) endifendif endforendfor?max=,max,min=,min19. 對三個整數(shù)從大到小排序clearinput a= to ainput b= to binput c= to cif ab t=a a
8、=b b=telse if ac t=a a=cc=t endifendifif bc t=b a=c c=tendif?a,b,c20. 對十個整數(shù)從大到小排序(用選擇法和起泡法兩種方法)選擇法:cleardime a(10)for i=1 to 10 input to a(i)endforfor i=1 to 9 max=a(i) num=i for j=i+1 to 10if maxa(j) max=a(j) num=jendif endfor if inum t=a(i) a(i)=a(num) a(num)=t endifendforfor i=1 to 10 ?a(i), endf
9、or起泡法:cleardime a(10)for i=1 to 10 input to a(i)endforfor i=1 to 9 for j=1 to 10-i if a(j)c and a+cb and b+ca p=(a+b+c)/2 s=sqrt(p*(p-a)*(p-b)*(p-c) ?selse ?三邊不能組成三角形endif27. 求二元方程的根(分三種情況:兩個不等實(shí)根,兩個相等實(shí)根,無實(shí)根)cleainpu a= to a &a0inpu b= to b &b0inpu c= to ci=b*b-4*a*c if i0 ?方程無實(shí)根! else if i=0 r=(-b)/
10、(2*a) ?方程有兩個相等實(shí)數(shù)根:,r else x1=(-b+sqrt(i)/(2*a) x2=(-b-sqrt(i)/(2*a) ?方程有兩個不相等實(shí)數(shù)根:,x1,x2 endifendif28. 輸入任意一個五位整數(shù),前后對應(yīng)位置上的數(shù)據(jù)進(jìn)行交換重新排列(即逆序排列)(例:2598448952)cleadime a(5)inpu to ba(1)=int(b/10000)a(2)=mod(int(b/1000),10)a(3)=mod(int(b/100),10)a(4)=mod(int(b/10),10)a(5)=mod(b,10)for i=1 to int(5/2) t=a(i)
11、 a(i)=a(6-i) a(6-i)=tendforc=a(1)*10000+a(2)*1000+a(3)*100+a(4)*10+a(5)?b,c29. 找出一個3x3矩陣的“鞍點(diǎn)”,即該位置上的元素在該行上最大,在該列上最小(也有可能沒有鞍點(diǎn))cleadime a(3,3) flag=.t.for i=1 to 3 for j=1 to 3 input a(+str(i,2)+,+str(j,2)+)= to a(i,j) endforendfor for i=1 to 3 max=a(i,1) col=1 for j=2 to 3 if maxa(k,col) min=a(k,col) row=k endif endfor if max=min ?a(row,col),是鞍點(diǎn),在,row,行,col,列 flag=.f. endifendf
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 編曲師崗位面試問題及答案
- 影視特效合成師崗位面試問題及答案
- 系統(tǒng)安全工程師崗位面試問題及答案
- 湖北省武漢市華大新2025年高一下化學(xué)期末教學(xué)質(zhì)量檢測模擬試題含解析
- 安徽省名校2025屆高一下化學(xué)期末監(jiān)測試題含解析
- 2025屆安徽定遠(yuǎn)示范高中高二下化學(xué)期末統(tǒng)考試題含解析
- 山東省鄒城市第一中學(xué)2025年化學(xué)高二下期末質(zhì)量跟蹤監(jiān)視模擬試題含解析
- 檔案收費(fèi)存放管理辦法
- 軍用專用倉庫管理辦法
- 混合現(xiàn)實(shí)教學(xué)應(yīng)用-洞察及研究
- 計算廣告學(xué)-第四章課件
- 技術(shù)入股分紅合同協(xié)議書范本
- 小紅書獨(dú)家授權(quán)委托書模板
- 1-國家1+X證書制度解讀講解
- 萬科物業(yè)服務(wù)工作手冊
- 人教版小學(xué)英語單詞表(完整版)
- 共享工作室租賃合同
- DL-T 1476-2023 電力安全工器具預(yù)防性試驗(yàn)規(guī)程
- 無人機(jī)航空測繪與后期制作 課件 第二十二課時 ContextCapture傾斜攝影測量數(shù)據(jù)處理流程-空三加密
- 三板大斧子小品《反詐銀行》臺詞劇本
- 溧陽市安息堂規(guī)劃建設(shè)方案
評論
0/150
提交評論