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

正文內(nèi)容

[理學(xué)]c語(yǔ)言作業(yè)答案(編輯修改稿)

2024-11-12 20:23 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 ntf(Good evening\n)。break。 case 4:printf(Good night\n)。break。 default:printf(Byebye\n)。 } } case和 1之間要有 空格 。 break不能省略! 實(shí)驗(yàn) ,以 0結(jié)束,判斷并輸出其中的最大數(shù)。 include void main() { int a,max。 printf(please input some numbers with 0 end:)。 scanf(%d,amp。a)。 max=a。 while(a!=0) { if(amax) max=a。 scanf(%d,amp。a)。 } printf(max=%d\n,max)。 } 實(shí)驗(yàn) 5_2. 輸入一行字符,以回車鍵作為結(jié)束標(biāo)志,分別統(tǒng)計(jì)出大寫字母、小寫字母、空格、數(shù)字和其它字符的個(gè)數(shù)。 include void main() { char ch。 int cap=0,alp=0,spa=0,num=0,other=0。 printf(please input some letters:)。 ch=getchar( ) 。 while(ch!=39。\n39。) { if(ch=39。039。amp。amp。ch=39。939。) num++。 else if(ch=39。A39。amp。amp。ch=39。Z39。) cap++。 else if(ch=39。a39。amp。amp。ch=39。z39。) alp++。 else if(ch==39。 39。) spa++。 else other++。 ch=getchar( ) 。 } printf(Capital letter=%d,Lowercase letter=%d, Number=%d,Space=%d,Others=%d\n,cap,alp,num,spa,other)。 } while((ch=getchar())!=39。\n39。) { if(ch=39。039。amp。amp。ch=39。939。) num++。 else if(ch=39。A39。amp。amp。ch=39。Z39。) cap++。 else if(ch=39。a39。amp。amp。ch=39。z39。) alp++。 else if(ch==39。 39。) spa++。 else other++。 } 作業(yè) ,以 32767結(jié)束,分別統(tǒng)計(jì)出正整數(shù)、負(fù)整數(shù)和 0的個(gè)數(shù)并輸出。 include void main() { int a。 int positive=0,negative=0,zero=0。 printf(please input some numbers:)。 scanf(%d,amp。a)。 while(a!=32767) { if(a0) positive++。 else if(a0) negative++。 else zero++。 scanf(%d,amp。a)。 } printf(“Positive number=%d, Negative number=%d, Zero=%d\n, positive, negative, zero)。 } 實(shí)驗(yàn) 5_4. 分別用 while、 dowhile和 for語(yǔ)句計(jì)算 1! +2! +3! +…+20 ! (方法一) while語(yǔ)句: void main() { int i。 float t=1, sum=0。 i=1。 while (i=20) { t=t*i。 sum=sum+t。 i++。 } printf (sum=%.0f\n, sum)。 } 此處分號(hào)不要漏掉 dowhile語(yǔ)句: do { t=t*i。 sum=sum+t。 i++。 } while (i=20)。 實(shí)驗(yàn) 5_4. 分別用 while、 dowhile和 for語(yǔ)句計(jì)算 1! +2! +3! +…+20 ! (方法一) while語(yǔ)句: void main() { int i。 float t=1, sum=0。 i=1。 while (i=20) { t=t*i。 sum=sum+t。 i++。 } printf (sum=%.0f\n, sum)。 } for語(yǔ)句: void main() { int i。 float t=1, sum=0。 for (i=1。i=20。i++) { t=t*i。 sum=sum+t。 } printf (sum=%.0f\n, sum)。 } 當(dāng) for的循環(huán)體有多條語(yǔ)句時(shí), { }不能省略! 實(shí)驗(yàn) 5_4. 分別用 while、 dowhile和 for語(yǔ)句計(jì)算 1! +2! +3! +…+20 ! (方法二) for語(yǔ)句: void main() { int i,j。 float sum=0,temp。 printf(sum=%.0f\n,sum)。 } while語(yǔ)句: i=1。 while(i=20) { temp=1。 sum=sum+temp。 i++。 dowhile語(yǔ)句: i=1。 do { sum=sum+temp。 i++。 }while(i=20)。 temp=1。 for(j=1。j=i。j++) temp=temp*j。 j=1。 while(j=i) { temp=temp*j。 j++。 } temp=1。 j=1。 do { temp=temp*j。 j++。 }while(j=i)。 for(i=1。i=20。i++) { sum=sum+temp。 } 分析:設(shè) x1為前一年 GDP,設(shè) x2為第二年 GDP, 則 x2=x1* void main() { int n=0。 float x1,x2。 x1=。 x2=x1。 while(x2) { x2=x1*。 x1=x2。 n++。 } printf(year=%d\n,n)。 } x2=x1*(1+%) %:求余運(yùn)算符 ( GDP)每年遞增 %,編寫程序計(jì)算并輸出需要多少年國(guó)民生產(chǎn)總值才能翻一番。 (方法一) ( GDP)每年遞增 %,編寫程序計(jì)算并輸出需要多少年國(guó)民生產(chǎn)總值才能翻一番。 (方法二) void main() { int n=0。 float GDP。 scanf(%f,amp。GDP)。 while(GDP2*GDP) { GDP=GDP*。 n++。 } printf(year=%d\n,n)。 } void main() { int n=0。 float GDP,g。 scanf(%f,amp。GDP)。 g=GDP。 while(GDP2*g) { GDP=GDP*。 n++。 } printf(year=%d\n,n)。 } 6_1_2. 輸出所有的水仙花數(shù)。 (水仙花數(shù)就是一個(gè)三位數(shù),這個(gè)數(shù)正好等于該數(shù)的每一位的立方和。 例如: 153=1*1*1+5*5*5+3*3*3) void main() { int a,b,c,i。 for(i=100。i=999。i++) { a=i/100。 //百位數(shù) b=i%100/10。 //十位數(shù) c=i%10。 //個(gè)位數(shù) if(i==a*a*a+b*b*b+c*c*c) printf(%5d,i)。 } } * *** ***** ******* ********* *********** 特點(diǎn):一共有 6行,第 i行有 2i1個(gè)星號(hào);第 i行的第 1個(gè)星號(hào)前有 6i個(gè)空格 include void main( ) { int i , j 。 for( i=1。 i=6。 i++) { for (j=1。 j=6i。 j++) putchar(32)。 for (j=1。 j=2*i1。 j++) putchar(39。*39。)。 putchar
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1