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

正文內容

最新c語言程序設計何欣銘、顏暉第2版課后習題答案終稿(參考版)

2025-07-01 04:24本頁面
  

【正文】
。素數(shù)就是只能被 1 和自身整除的正整數(shù),1 不是素數(shù),2 是素數(shù)。 printf( %d , digit)。if (x0) x=x while (x != 0){ digit = x %10。 scanf( “%d”, amp。解答:include int main(void) { int x。 練習 411 輸入一個整數(shù),將其逆序輸出。 } printf(min = %d\n, min)。x)。 i n。 min = x。 scanf(%d, amp。n)。 printf(inputr n: )。練習 410 輸入一個正整數(shù) n, 再輸入 n 個整數(shù),輸出最小值。 } return 0。 if (max mark) max = mark。 i++ ){ scanf (%d, amp。 /* 假設第一個成績是最高分 */ for (i = 1。mark)。 if (n0) { printf(Enter %d marks: , n)。 scanf (%d, amp。 練習 48 運行例 48 的源程序 1 時,如果先輸入 0,即輸入數(shù)據(jù)個數(shù) n=0,表示不再輸入任何成績,運行結果是什么?如何修改程序以應對這種情況?解答:當輸入數(shù)據(jù)個數(shù) n=0 時,由于在 for 循環(huán)外首先得輸入一個成績,故程序仍將等待輸入第一個人的成績,這與輸入個數(shù) n=0 矛盾,可修改如下:include int main(void) { int i, mark, max, n。 } printf(e = %\n, e)。j++) t = t * j。 for(j=1。 i = n。 e = 1。 scanf(%d, amp。 double e, t。 } } 練習 47 輸入 1 個正整數(shù) n,計算下式求出 e 的值(保留 2 位小數(shù)),要求使用嵌套循環(huán)。 else printf(%d is39。amp。 j++) if(m % j == 0) break。 for(j = 2。m)。 i = n。n)。解答:include include int main(void) { int flag, i, j, k, m, n。練習 46 輸入一個正整數(shù) n, 再輸入 n 個正整數(shù),判斷它們是否為素數(shù)。 else printf(%d is prime number!\n,m)。 i = m/2。 ”。 } 解答:會有影響,因為當輸入數(shù)據(jù) number 為 0 時,上述 while 循環(huán)將不執(zhí)行,count 值仍為 0,故輸出為 0,不符合題目要求。 } 練習 44 如果將例 43 程序中的 dowhile 語句改為下列 while 語句,會影響程序的功能嗎?為什么?再增加一條什么語句,就可以實現(xiàn)同樣的功能?while(number != 0){ number = number / 10。 } printf ( “s = %f\n”, s)。 flag = flag。 while(fabs (item) = eps) { item = flag * / denominator。 scanf(“%lf”,amp。 item = 。 flag = 1。11111解答:s = 1 + + + L4 7 10 13 16include include int main(void) { int denominator, flag。如果第一個輸入數(shù)據(jù)是1,運行結果是:Grade average is 0,因為第一個輸入就是1,則 while 循環(huán)條件不成立,不執(zhí)行循環(huán)體。如果將精度改為 103,運行結果會有變化,因為精度改變意味著 while 循環(huán)的條件改變,精度變大使得 while 循環(huán)次數(shù)減少,必然影響到 pi 的值。本章總結?正確理解?正確理解 while語句和 dowhile歸納總結本章的各個重要知識點。amp。 child = 45。 women = 45。 men++)比較循環(huán)次數(shù)法。引導學生考慮:上述三重循環(huán)的循環(huán)體(if語句)共執(zhí)行了多少次?是否可減少循環(huán)次數(shù)?說明如何把三重循環(huán)改成二重循環(huán)?并比較循環(huán)體的執(zhí)行次數(shù),分析減少的方for (men = 0。引導學生分析問題,男人、女人和小孩的人數(shù)取值范圍均在 0~45 之間,只要能滿足總人數(shù)為 45 人且所搬的磚為 45 塊就是一種搬法,顯然要對男人、女人和小孩三個人數(shù)的各種可能一一測試,來找出滿足條件的人員組合,可采用三重循環(huán)。if (men * 3 + women * 2 + child * == 45)printf(men=%d women=%d child=%d\n, men, women, child)。 women = 22。 men = 15。 (men*3+women*2+child*==45))printf(men=%d women=%d child=%d\n, men, women, child)。 child++)if ((men+women+child==45) amp。 women++)for (child = 0。 men++)for (women = 0。問用45人正好搬45塊磚,有多少種搬法?for (men = 0。三角形面積計算公式: area=s(s a)(s b)(s c)其中 s = (a+b+c)/2 輸入輸出示例(運行 2 次) 第一次運行: Enter 3 sides of the triangle: 5 5 3 area = 。 } 實驗指導教材參考答案一、調試示例:略二、改錯題改正下列程序中的錯誤,輸入三角形的 3 條邊 a, b, c,如果能構成一個三角形,輸出面積 area 和周長 perimeter(保留 2 位小數(shù));否則,輸出“These sides do not correspond to a valid triangle”。 year%100!=0) || (year%400==0)) printf(%d\n,year)。 year++){ if( (year%4==0 amp。 for(year=2000。判斷閏年的條件是:能被 4 整除但不能被 100 整除,或者能被 400 整除。 return 0。 printf(average=%.1f\n,average)。 else counte++。 else if(mark=70) countc++。 if(mark=90) counta++。mark)。 i=n。 counta= countb = countc = countd = counte =sum=0。 scanf(%d,amp。 int counta, countb, countc, countd, counte。include int main(void) { int mark, n, i, sum。 } 4.輸入一個正整數(shù) n,再輸入 n 個學生的成績,計算平均分,并統(tǒng)計各等級成績的個數(shù)。 printf(cost=%d\n,cost)。 else if(mile=13) cost=10+(mile3)*2。 mile=mile+time/5。time)。 scanf(%d%d,amp。編寫程序,輸入行駛里程(公里)與等待時間(分鐘),計算并輸出乘客應支付的車費(元)。運價計費尾數(shù)四舍五入,保留到元。 3.某城市普通出租車收費標準如下:“起步里程 3 公里,起步費 10 元;超起步里程后 10公里內,每公里租費 2 元,超過 10 公里以上的部分加收 50%的回空補貼費,即每公里租費3 元。 printf(tax = %.0f\n,tax)。decution=13505。decution=5505。decution=2755。decution=1005。decution=555。decution=105。decution=0。decution=0。salary)。 printf(Enter the salary: )。新稅法方案如下:tax = rate * (salary3500) deduction 當 salary ≤3500 時,rate = 0、deduction = 0 當 3500 <salary ≤5000 時,rate = 3%、deduction = 0 當 5000 < salary ≤ 8000 時,rate = 10%、deduction = 105 當 8000 < salary ≤ 12500 時,rate = 20%、deduction = 555 當 12500 < salary ≤ 38500 時,rate = 25%、deduction = 1005 當 38500 < salary ≤ 58500 時,rate = 30%、deduction = 2755 當 58500 < salary ≤ 83500 時,rate = 35%、deduction = 5505 當 83500 < salary 時,rate = 45%、deduction = 13505 解答: include int main(void) { int decution。 return 0。 printf(area=%.2f,perimeter=%.2f\n,area,perimeter)。 s=(a+b+c)*。amp。amp。c)。a,amp。 double area,s,perimeter。在一個三角形中,任意兩邊之和大于第三邊。 return 0。: k = k + 3。 case 39。b39。break。a39。 int k = 4。int main(void) { char c = return 0。 if(a 40) printf(%d,a)。a)。int main(void) { int a。!cb 的值為 0 。ca||abamp。3.已知 a=,b=2,c=,則表達式 abamp。2.若有 int x。amp。 return 0。 else t = 2 * s。 if(a b) t = s + t。 t = 1。b)。 scanf(%d,%d,amp。 } A.a(chǎn)=2,b=1 B.a(chǎn)=1,b=1 C.a(chǎn)=1,b=0 D.a(chǎn)=2,b=2 7.在執(zhí)行以下程序時,為使輸出結果為:t=4,則給 a 和 b 輸入的值應滿足的條件是 C 。 } printf(a=%d,b=%d\n,a,b)。 case 1: a++ case 2: a++。int main(void) { int x = 1,a = 0,b = 0。 return 0。 else c++。int main(void) { int a = 2, b = 1,c = 2。 else y = 1。 D.if(x = 0) if(x 0) y = 1。 if(x 0) y = 1。 else y = 1。 if(x = 0)。 else y = 1。 1 x 0A.if(x 0) y = 1。239。=4.有一函數(shù) y237。A.break 語句只能用于switch 語句B.在switch 語句中必須使用default C.break 語句必須與switch 語句中的case 配對使用D.在switch 語句中,不一定使用break語句236。 a = 0 B.a(chǎn) = 0 | a = 10 D.a(chǎn) = 10 || a = 0 2.在嵌套使用if 語句時,C 語言規(guī)定else 總是 C 。A.a(chǎn) = 10 or
點擊復制文檔內容
環(huán)評公示相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1