freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c程序設(shè)計(jì)04判定、分支和循環(huán)[組織行為管理推薦(編輯修改稿)

2025-02-08 07:50 本頁面
 

【文章內(nèi)容簡介】 l 用 Switch Statement. ? 循環(huán) ? 概述 C語言可實(shí)現(xiàn)循環(huán)的語句: ? 用 goto 和 if 構(gòu)成循環(huán) ? while 語句 ? do ~ while 語句 ? for 語句 ? goto語句 一般格式 p132-轉(zhuǎn)移作用 goto 語句標(biāo)號; ….….. 標(biāo)號:語句; 標(biāo)號:語句; ….….. goto 語句標(biāo)號; ?不能用整數(shù)作標(biāo)號 ?只能出現(xiàn)在 goto所在函數(shù)內(nèi) ,且唯一 ?只能加在可執(zhí)行語句前面 ?限制使用 goto語句 例 用 if 和 goto語句構(gòu)成循環(huán),求 1+2+…+100 /*loop using goto statement*/ include main() { int i,sum=0。 i=1。 loop: if(i=100) { sum+=i。 i++。 goto loop。 } printf(%d,sum)。 } sum=0+1 sum==1+2=3 sum=3+3=6 sum=6+4 …… sum=4950+100=5050 循環(huán)初值 循環(huán)終值 循環(huán)變量增值 循環(huán)條件 循環(huán)體 例 從鍵盤輸入一組數(shù)據(jù),以 0結(jié)束輸入,求數(shù)據(jù)和 /*sum of data*/ include main() { int number,sum=0。 read_loop: scanf(%d,amp。number)。 if(!number) goto print_sum。 sum+=number。 goto read_loop。 print_sum: printf(The total sum is %d\n,sum)。 } 例 輸入 10個(gè)男孩的身高和體重,統(tǒng)計(jì)身高超過 170體重少于 50公斤的人數(shù)。 例 pp135 RANGE of Numbers: A survey of the puter macket show that personal puters are sold at varying costs bythe following is the list of costs(in hundreds)quoted by some vendors: , , , , , , , , , Determine the average cost and the range of values. 例 pp136 PayBill Calculations: A manufacturing pany has classified its executives into four levels for the benefit of certain perks. The levels and corresponding perks are shown below: Perks Level Conveyance Entertainment allowance allowance 1 1000 500 2 750 200 3 500 100 4 250 An executive’s gross salary includes basic pay, house rent allowance at 25% of basic pay and other perks. Ine tax is withheld from the salary on a percentage basis as follows: Gross salary Tax rate Gross=2022 No tax deduction 2022Gross=4000 3% 4000Gross=5000 5% Gross5000 8% Write a program that will read an executive’s job number, level number, and basic pay and then puter the salary after withholding ine tax. The problem is detailed in the program. ?while語句 p147 ?一般形式: while(表達(dá)式 ) 循環(huán)體語句; ?執(zhí)行流程: expr 循環(huán)體 假 (0) 真 (非 0) while ?特點(diǎn):先判斷表達(dá)式,后執(zhí)行循環(huán)體 ?說明: ?循環(huán)體有可能一次也不執(zhí)行 ?循環(huán)體可為任意類型語句 ?下列情況,退出 while循環(huán) ?條件表達(dá)式不成立(為零) ?循環(huán)體內(nèi)遇 break,return,goto ?無限循環(huán) : while(1) 循環(huán)體 。 例 用 while循環(huán)求 1+2+…+100 /*sum of 1 to 100*/ include main() { int i,sum=0。 i=1。 while(i=100) { sum=sum+i。 i++。 } printf(%d,sum)。 } 循環(huán)初值 循環(huán)終值 循環(huán)變量增值 循環(huán)條件 循環(huán)體 例 顯示 1~10的平方 /*square of every number*/ include main() { int i=1。 while(i=10) { printf(%d*%d=%d\n,i,i,i*i)。 i++。 } } 運(yùn)行結(jié)果: 1*1=1 2*2=4 3*3=9 4*4=16 5*5=25 6*6=36 7*7=49 8*8=64 9*9=81 10*10=100 ?do~while語句 p150 ?一般形式: do 循環(huán)體語句; while(表達(dá)式 )。 ?執(zhí)行流程: do 循環(huán)體 expr 假 (0) 真 (非 0) while ?特點(diǎn):先執(zhí)行循環(huán)體,后判斷表達(dá)式 expr 循環(huán)體 假 (0) 真 (非 0) 循環(huán)體 While循環(huán) ?至少執(zhí)行一次循環(huán)體 ?do~while可轉(zhuǎn)化成 while結(jié)構(gòu) 例 用 do~while循環(huán)求 1+2+…+100 /**/ include main() { int i,sum=0。 i=1。 do { sum+=i。 i++。 }while(i=100)。 printf(%d,sum)。 } 例 while和 do~while比較 include main() { int i,sum=0。 scanf(%d,amp。i)。 do { sum+=i。 i++。 }while(i=10)。 printf(%d,sum)。 } include main() { int i,sum=0。 scanf(%d,amp。i)。 while(i=10) { sum+=i。 i++。 } printf(%d,sum)。 } ?for語句 p152 ?一般形式: for([expr1] 。[ expr2] 。[ expr3]) 循環(huán)體語句; ?執(zhí)行流程: expr2 循環(huán)體 假 (0) 真 (非 0) for expr1 expr3 ?for語句一般應(yīng)用形式 : for(循環(huán)變量賦初值;循環(huán)條件;循環(huán)變量增值 ) { 循環(huán)體語句; } expr1。 while(expr2) { 循環(huán)體語句; expr3。 } 例 用 for循環(huán)求 1+2+…+100 include main() { int i,sum=0。 for(i=1。i=100。i++) sum+=i。 printf(%d,sum)。 } ?for語句中 expr1, expr2 ,expr3 類型任意,都可省略,但分號;不可省 ?無限循環(huán) : for(。) ?for語句可以轉(zhuǎn)換成 while結(jié)構(gòu) ? ? 溫故?逗號運(yùn)算符 p154 例 用 for循環(huán) 生成 10個(gè)隨機(jī)數(shù)并累加 include include include main() { int i, tmp, sum=0。 /* Seed the random
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1