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

正文內(nèi)容

c語言習(xí)題與答案愛課程mooc(編輯修改稿)

2024-07-25 08:13 本頁面
 

【文章內(nèi)容簡(jiǎn)介】 60。grade=39。C39。16. elseif(score=60)17. grade=39。D39。18. else19. grade=39。E39。20. printf(grade:%c\n,grade)。21. return0。22. }程序運(yùn)行結(jié)果示例1:Please input score:a↙Input error!Please input score:12↙Input error!Please input score:230↙Input error!Please input score:92↙grade: A程序運(yùn)行結(jié)果示例2:Please input score:88↙grade: B程序運(yùn)行結(jié)果示例3:Please input score:73↙grade: C程序運(yùn)行結(jié)果示例4:Please input score:65↙grade: D程序運(yùn)行結(jié)果示例5:Please input score:27↙grade: E輸入格式:%d輸出格式:輸入提示信息:Please input score:\n輸入錯(cuò)誤提示信息:Input error!\n輸出格式:grade: %c\n (注意:%c前面有一個(gè)空格)輸入樣例:輸出樣例:includeint main(){ int score,m=0。 char grade。 printf(Please input score:\n)。 do{ m=scanf(%d, amp。score)。 getchar()。 if (m!=1 ||score 0 || score 100) { printf(Input error!\nPlease input score:\n)。m=0。} }while (m==0)。 if (score = 90) grade = 39。A39。 else if (score = 80) grade = 39。B39。 else if (score = 70) grade = 39。C39。 else if (score = 60) grade = 39。D39。 else grade = 39。E39。 printf(grade: %c\n, grade)。 return 0。}編程計(jì)算a+aa+aaa+…+aa…a(n個(gè)a)的值(4分)題目?jī)?nèi)容:編程計(jì)算 a+aa+aaa+…+aa…a(n個(gè)a)的值,n和a的值由鍵盤輸入。例如,當(dāng)n=4,a=2,表示計(jì)算2+22+222+2222的值。程序運(yùn)行結(jié)果示例:Input a,n:2,4↙sum=2468輸入格式: %d,%d(先輸入a,后輸入n)輸出格式: 輸入提示信息:Input a,n:\n輸出格式:sum=%ld\n%ld\n輸入樣例:輸出樣例:include int main(){ int a,n,sum=0,tem=1。 printf(Input a,n:\n)。 scanf(%d,%d,amp。a,amp。n)。 int i。 for (i=1。i=n。i++) { sum+=(a*tem)。 tem=tem*10+1。 } printf(sum=%d\n,sum)。 return 0。}搬磚問題(4分)題目?jī)?nèi)容:36塊磚,36人搬,男搬4,女搬3,兩個(gè)小孩抬一塊磚,要求一次搬完,問男人、女人和小孩各需多少人?請(qǐng)用窮舉法編程求解。程序的運(yùn)行結(jié)果示例:men=3,women=3,children=30輸入格式: 輸出格式:men=%d,women=%d,children=%d\n輸入樣例:輸出樣例:include int main(){ int woman,man,kid。 for (woman=0。woman=12。woman++) { for (man=0。man=9。man++) { kid=36manwoman。 if (4*man+3*woman+*kid==36) printf(men=%d,women=%d,children=%d\n,man,woman,kid)。 } } return 0。}編程輸出某年某月有多少天(考慮閏年)。(5分)題目?jī)?nèi)容:從鍵盤輸入一個(gè)年份和月份,輸出該月有多少天(考慮閏年),用switch語句編程。程序運(yùn)行結(jié)果示例1:Input year,month:2015,3↙31 days程序運(yùn)行結(jié)果示例2:Input year,month:2015,4↙30 days程序運(yùn)行結(jié)果示例3:Input year,month:2016,2↙29 days程序運(yùn)行結(jié)果示例4:Input year,month:2014,2↙28 days程序運(yùn)行結(jié)果示例5:Input year,month:2015,13↙Input error!輸入格式:%d,%d輸出格式:輸入提示信息:Input year,month:\n輸入錯(cuò)誤提示信息:Input error!\n輸出格式: 31 days\n 30 days\n 29 days\n 28 days\n 輸入樣例輸出樣例include int isleap(int n)。int main(){ int year,month。 printf(Input year,month:\n)。 scanf(%d,%d,amp。year,amp。month)。 switch (month){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: printf(31 days\n)。break。 case 4: case 6: case 9: case 11:printf(30 days\n)。break。 case 2:if (isleap(year)) { printf(29 days\n)。break。 } else{ printf(28 days\n)。break。 } default : printf(Input error!\n)。 } return 0。}int isleap(int n){ if (n%100!=0amp。amp。n%4==0||n%400==0) return 1。 else return 0。}第七章遞歸法計(jì)算游戲人員的年齡(4分)題目?jī)?nèi)容:有n個(gè)人圍坐在一起,問第n個(gè)人多大年紀(jì),他說比第n1個(gè)人大2歲;問第n1個(gè)人,他說比第n2個(gè)人大2歲,.....,問第3個(gè)人,他說比第2個(gè)人大2歲;問第2個(gè)人,他說比第1個(gè)人大2歲。第1個(gè)人說自己10歲,問第n個(gè)人多大年紀(jì)。遞歸函數(shù)原型:unsigned int ComputeAge(unsigned int n)。提示:遞歸公式輸入格式:%u輸出格式:The person39。s age is %u\n輸入樣例1:5↙輸出樣例1:The_person39。s_age_is_18輸入樣例2:10↙輸出樣例2:The_person39。s_age_is_28注意:為避免出現(xiàn)格式錯(cuò)誤,請(qǐng)直接拷貝粘貼上面給出的輸入、輸出提示信息和格式控制字符串!(注意:在輸出中,“_”代表空格,如果直接將上段示例粘貼到代碼中,應(yīng)將其替換為空格。)include unsigned int Age(unsigned int age)。int main(){ unsigned int n=0。 scanf(%ud,amp。n)。 printf(The person39。s age is %u\n,Age(n))。 return 0。}unsigned int Age(unsigned int n){ if (n==1) return 10。 else return Age(n1)+2。}魔術(shù)師猜數(shù)(4分)題目?jī)?nèi)容:在一種室內(nèi)互動(dòng)游戲中,魔術(shù)師要每位觀眾心里想一個(gè)三位數(shù)abc(a、b、c分別是百位、十位和個(gè)位數(shù)字),然后魔術(shù)師讓觀眾心中記下acb、bac、bca、cab、cba五個(gè)數(shù)以及這5個(gè)數(shù)的和值。只要觀眾說出這個(gè)和是多少,則魔術(shù)師一定能猜出觀眾心里想的原數(shù)abc是多少。例如,觀眾甲說他計(jì)算的和值是1999,則魔術(shù)師立即說出他想的數(shù)是443,而觀眾乙說他計(jì)算的和值是1998,則魔術(shù)師說:“你算錯(cuò)了!”。請(qǐng)編程模擬這個(gè)數(shù)字魔術(shù)游戲。要求用函數(shù)實(shí)現(xiàn),函數(shù)原型:int Magic(int m);其中形參m代表觀眾計(jì)算的和值。輸入格式:%d輸出格式:觀眾計(jì)算錯(cuò)誤,魔術(shù)師給出的結(jié)論:The sum you calculated is wrong!\n觀眾計(jì)算正確,魔術(shù)師給出的結(jié)論:The number is %d\n輸入樣例1:1998↙輸出樣例1:The_sum_you_calculated_is_wrong!輸入樣例2:1999↙輸出樣例2:The_number_is_443注意:為避免出現(xiàn)格式錯(cuò)誤,請(qǐng)直接拷貝粘貼上面給出的輸入、輸出提示信息和格式控制字符串?。ㄗ⒁猓涸谳敵鲋?,“_”代表空格,如果直接將上段示例粘貼到代碼中,應(yīng)將其替換為空格。)include int Magic(int m)。int main(){ int m。 scanf(%d,amp。m)。 if( Magic(m)) printf(The number is %d\n,Magic(m))。 else printf(The sum you calculated is wrong!\n)。 return 0。}int Magic(int n){ int m。 int a,b,c。 for (m=100。m1000。m++){ a=m/100。 c=m%10。 b=(ma*100)/10。 if ((a*122+b*212+c*221)==n) return m。 } return 0。}(4分)題目?jī)?nèi)容:編寫一個(gè)函數(shù)返回三個(gè)整數(shù)中的中間數(shù)。函數(shù)原型:int mid(int a, int b, int c)。 功能是返回a,b,c三數(shù)中大小位于中間的一個(gè)數(shù)。輸入格式:%d%d%d輸出格式:The result is %d\n輸入樣例1:12 6 18↙輸出樣例1:The_result_is_12輸入樣例2:9 7 2↙輸出樣例2:The_result_is_2注意:為避免出現(xiàn)格式錯(cuò)誤,請(qǐng)直接拷貝粘貼上面給出的輸入、輸出提示信息和格式控制字符串?。ㄗ⒁猓涸谳敵鲋?,“_”代表空格,如果直接將上段示例粘貼到代碼中,應(yīng)將其替換為空格。)include int mid(int a, int b, int c)。int main(){ int a,b,c。
點(diǎn)擊復(fù)制文檔內(nèi)容
規(guī)章制度相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1