實驗一程序流程設計.ppt_第1頁
實驗一程序流程設計.ppt_第2頁
實驗一程序流程設計.ppt_第3頁
實驗一程序流程設計.ppt_第4頁
實驗一程序流程設計.ppt_第5頁
已閱讀5頁,還剩24頁未讀, 繼續(xù)免費閱讀

VIP免費下載

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

實驗一程序流程設計 1 理解大小寫轉換函數(shù) 在文本框中輸入文本串 按 轉大寫 按鈕 文本中的英文字母變?yōu)榇髮?按 轉小寫 按鈕 文本中的英文字母變?yōu)樾?如圖所示 設計代碼方法一 首先設計文本框的InteractiveChange事件代碼 使得輸入的字符存入表單的Tag屬性 用來存儲程序所需的任何額外數(shù)據(jù) 中 thisform tag this value編寫 大寫 按鈕Command1的Click事件代碼 thisform text1 value upper thisform tag 編寫 小寫 按鈕Command2的Click事件代碼 thisform text1 value lower thisform tag 編寫 復原 按鈕Command2的Click事件代碼 thisform text1 value thisform tag 方法二 首先在表單的load事件代碼中聲明一個全局變量a Publica設計文本框的InteractiveChange事件代碼 使得輸入的字符存入表單的Tag屬性 用來存儲程序所需的任何額外數(shù)據(jù) 中 a this value編寫 大寫 按鈕Command1的Click事件代碼 thisform text1 value upper a 編寫 小寫 按鈕Command2的Click事件代碼 thisform text1 value lower a 編寫 復原 按鈕Command2的Click事件代碼 thisform text1 value a 2 輸入3個不同的數(shù) 將他們從大到小排序 分析 先將a與b比較 把較大者放入a中 小者放入b中 再將a與c比較 把較大者放入a中 小者放入c中 此時a為三者中的最大者 最后將b與c比較 把較大者放入b中 小者放入c中 此時a b c已由大到小順序排列 流程圖如下 編寫Command1的Click事件代碼 a thisform text1 valueb thisform text2 valuec thisform text3 valueIFb ad aa bb dENDIFIFc ad aa cc dENDIF IFc bd bb cc dENDIFthisform label2 caption STR a 4 thisform label3 caption STR b 4 thisform label4 caption STR c 4 3 設計個人納稅計算程序 稅法 規(guī)定 工資 薪金所得 使用超額累進稅率 以每月收入額減去800元后的余額 為應納稅所得額 其稅率表見表5 3 Text1的KeyPress事件代碼 LPARAMETERSnKeyCode nShiftAltCtrlIFnKeyCode 13n val this value IFn 800MESSAGEBOX 不超過800元 不必納稅 ELSES1 500 0 05S2 2000 0 15S3 5000 0 2S4 20000 0 25S5 40000 0 3S6 60000 0 35S7 80000 0 4S8 100000 0 45n n 800 DOCASECASEn 500s n 0 05CASEn 2000s n 500 0 1 s1CASEn 5000s n 2000 0 15 s2CASEn 20000s n 5000 0 2 s3CASEn 40000s n 20000 0 25 s4CASEn 60000s n 40000 0 3 s5CASEn 80000s n 60000 0 35 s6 CASEn 100000s n 80000 0 4 s7OTHERWISEs n 100000 0 45 s8ENDCASEthisform label2 caption 共計納稅 STR round s 2 8 2 元 this SelStart 0this SelLength LEN this value ENDIFENDIF 4 完備數(shù) 是指一個數(shù)恰好等于它的因子之和 如6的因子為1 2 3 而6 1 2 3 因而6就是完備數(shù) 編制程序 找出1 1000之間的全部 完備數(shù) 分析 依題意可知 要想知道一個自然數(shù)是否為完備數(shù) 首先必須找除其所有因數(shù) 從2開始到這個數(shù)的最打因數(shù)為止 偶數(shù)不大于其值的二分之一 奇數(shù)不大于其值的三分之一 進行整除判斷 凡是可以被整除的數(shù)均為這個數(shù)的因數(shù) 由此 可畫出其流程圖 編寫Command1的Click事件代碼 thisform container1 list1 clearforn 1to1000t iif n 2 0 n 2 n 3 a 2s 1dowhilea tifn a 0s s aendifa a 1enddoifs nthisform container1 list1 additem str n 6 endifendfor 編寫Command2的Click事件代碼 releasethisform 5 輸出99乘法表 格式如下圖 1 利用雙重循環(huán)分別處理行 列的輸出 編寫Command1的Click事件代碼 Thisform list1 clearThisform list1 addlistitem 1 1 fork 1to9Thisform list1 addlistitem str k 3 1 k 1 endforforn 1to9Thisform list1 addlistitem str n 3 n 1 1 fork 1tonThisform list1 addlistitem str k n 3 n 1 k 1 endforEndfor編寫Command2的Click事件代碼 releasethisform 6 小學生做加減法的算術練習程序 計算機連續(xù)地隨機給出兩位數(shù)的加減法算術題 要求學生回答 答對的打 答錯的打 將做過的題目存放在列表框中備查 并隨時給出答題的正確率 分析 隨機函數(shù)RAND 返回一個 0 1 之間的隨機小數(shù) 為了生成某個范圍內(nèi)的隨機整數(shù) 可以使用以下公式 Int 最大值 最小值 1 RAND 最小值 其中最大值和最小值為指定范圍中的最大 最小數(shù) 給出部分由窗體的激活 activate 事件代碼完成 a int 10 90 rand b int 10 90 rand p int 2 rand docasecasep 0this text1 value str a 3 str b 3 this text1 tag str a b 將本題答案放入text1 tag中casep 1ifa bt aa bb tendif this text1 value str a 3 str b 3 this text1 tag str a b 將本題答案放入text1 tag中endcasen val this tag this tag str n 1 this text2 setfocusthis text2 value 編寫Command1的Click事件代碼 ifval thisform text2 value val thisform text1 tag item allt thisform text1 text thisform text2 text k val thisform list1 tag thisform list1 tag str k 1 elseitem allt thisform text1 text thisform text2 text endifthisform list1 additem item 1 將題目和答案放入列表框中的第一項x vAL thisform list1 tag val thisform tag p 正確率為 chr 13 str x 100 5 2 thisform label1 caption 共 allt thisform tag 題 pthisform activate 調用出題代碼 7 使用命令按鈕組設計簡易計算器程序 如圖所示 編寫commandgroup1的click事件代碼 ifthisform tag T thisform text1 value allt right str this value 1 thisform tag elsea thisform text1 valuethisform text1 value a allt right str this value 1 endif編寫 按鈕command11的click事件代碼 a thisform text1 valuethisform text1 value a 編寫 按鈕command12的click事件代碼 a thisform text1 valuethisform text1 value allt str a thisform tag T 編寫 按鈕command12的click事件代碼 a thisform text1 valuethisform text1 value a thisform tag 編寫 按鈕command12的click事件代碼 a thisform text1 v

溫馨提示

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

評論

0/150

提交評論