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

正文內(nèi)容

c編程100例c語言c編程實例(編輯修改稿)

2024-09-26 15:24 本頁面
 

【文章內(nèi)容簡介】 fact(j) int j。 { int sum。 if(j==0) 13 sum=1。 else sum=j*fact(j1)。 return sum。 } ============================================================== 【程序 27】 題目:利用遞歸函數(shù)調(diào)用方式,將所輸入的 5 個字符,以相反順序打印出來。 : : include main() { int i=5。 void palin(int n)。 printf(\40:)。 palin(i)。 printf(\n)。 } void palin(n) int n。 { char next。 if(n=1) { next=getchar()。 printf(\n\0:)。 putchar(next)。 } else { next=getchar()。 palin(n1)。 putchar(next)。 } } ============================================================== 【程序 28】 題目:有 5 個人坐在一起,問第五個人多少歲?他說比第 4個人大 2歲。問第 4個人歲數(shù),他說比第 3 個人大 2 歲。問第三個人,又說比第 2 人大兩歲。問第 2個人,說比第一個人大兩歲。最后問第一個人,他說是 10 歲。請問第五個人多大? :利用遞歸的方法,遞歸分為回推和遞推兩個階段。要想知道第五個人歲數(shù),需知道第四人的歲數(shù),依次類推,推到第一人( 10 歲),再往回推。 : age(n) int n。 14 { int c。 if(n==1) c=10。 else c=age(n1)+2。 return(c)。 } main() { printf(%d,age(5))。 } ============================================================== 【程序 29】 題目:給一個不多于 5 位的正整數(shù),要求:一、求它是幾位數(shù),二、逆序打印出各位數(shù)字。 1. 程序分析:學會分解出每一位數(shù),如下解釋: : main( ) { long a,b,c,d,e,x。 scanf(%ld,amp。x)。 a=x/10000。/*分解出萬位 */ b=x%10000/1000。/*分解出千位 */ c=x%1000/100。/*分解出百位 */ d=x%100/10。/*分解出十位 */ e=x%10。/*分解出個位 */ if (a!=0) printf(there are 5, %ld %ld %ld %ld %ld\n,e,d,c,b,a)。 else if (b!=0) printf(there are 4, %ld %ld %ld %ld\n,e,d,c,b)。 else if (c!=0) printf( there are 3,%ld %ld %ld\n,e,d,c)。 else if (d!=0) printf(there are 2, %ld %ld\n,e,d)。 else if (e!=0) printf( there are 1,%ld\n,e)。 } ============================================================== 【程序 30】 題目:一個 5 位數(shù),判斷它是不是回文數(shù)。即 12321 是回文數(shù),個位與萬位相同,十位與千位相同。 : 同 29 例 : main( ) { long ge,shi,qian,wan,x。 scanf(%ld,amp。x)。 wan=x/10000。 qian=x%10000/1000。 shi=x%100/10。 ge=x%10。 if (ge==wanamp。amp。shi==qian)/*個位等于萬位并且十位等于千位 */ printf(this number is a huiwen\n)。 else printf(this number is not a huiwen\n)。 15 } 【程序 31】 題目:請輸入星期幾的第一個字母來判斷一下是星期幾,如果第一個字母一樣,則繼續(xù) 判斷第二個字母。 :用情況語句比較好,如果第一個字母一樣,則判斷用情況語句或 if 語句判斷第二個字母。 : include void main() { char letter。 printf(please input the first letter of someday\n)。 while ((letter=getch())!=39。Y39。)/*當所按字母為 Y 時才結(jié)束 */ { switch (letter) {case 39。S39。:printf(please input second letter\n)。 if((letter=getch())==39。a39。) printf(saturday\n)。 else if ((letter=getch())==39。u39。) printf(sunday\n)。 else printf(data error\n)。 break。 case 39。F39。:printf(friday\n)。break。 case 39。M39。:printf(monday\n)。break。 case 39。T39。:printf(please input second letter\n)。 if((letter=getch())==39。u39。) printf(tuesday\n)。 else if ((letter=getch())==39。h39。) printf(thursday\n)。 else printf(data error\n)。 break。 case 39。W39。:printf(wednesday\n)。break。 default: printf(data error\n)。 } } } ============================================================== 【程序 32】 題目: Press any key to change color, do you want to try it. Please hurry up! : : include void main(void) { int color。 for (color = 0。 color 8。 color++) { textbackground(color)。/*設(shè)置文本的背景顏色 */ 16 cprintf(This is color %d\r\n, color)。 cprintf(Press any key to continue\r\n)。 getch()。/*輸入字符看不見 */ } } ============================================================== 【程序 33】 題目:學習 gotoxy()與 clrscr()函數(shù) : : include void main(void) { clrscr()。/*清屏函數(shù) */ textbackground(2)。 gotoxy(1, 5)。/*定位函數(shù) */ cprintf(Output at row 5 column 1\n)。 textbackground(3)。 gotoxy(20, 10)。 cprintf(Output at row 10 column 20\n)。 } ============================================================== 【程序 34】 題目:練習函數(shù)調(diào)用 1. 程序分析: : include void hello_world(void) { printf(Hello, world!\n)。 } void three_hellos(void) { int counter。 for (counter = 1。 counter = 3。 counter++) hello_world()。/*調(diào)用此函數(shù) */ } void main(void) { three_hellos()。/*調(diào)用此函數(shù) */ } ============================================================== 【程序 35】 題目:文本顏色設(shè)置 : : 17 include void main(void) { int color。 for (color = 1。 color 16。 color++) { textcolor(color)。/*設(shè)置文本顏色 */ cprintf(This is color %d\r\n, color)。 } textcolor(128 + 15)。 cprintf(This is blinking\r\n)。 } ============================================================== 【程序 36】 題目:求 100 之內(nèi)的素數(shù) : : include include define N 101 main() { int i,j,line,a[N]。 for(i=2。iN。i++) a[i]=i。 for(i=2。isqrt(N)。i++) for(j=i+1。jN。j++) { if(a[i]!=0amp。amp。a[j]!=0) if(a[j]%a[i]==0) a[j]=0。} printf(\n)。 for(i=2,line=0。iN。i++) { if(a[i]!=0) {printf(%5d,a[i])。 line++。} if(line==10) {printf(\n)。 line=0。} } } ============================================================== 【程序 37】 題目:對 10 個數(shù)進行排序 :可以利用選擇法,即從后 9 個比較過程中,選擇一個最小的與第一個元素交換,下次類推,即用第二個元素與后 8 個 進行比較,并進行交換。 18 : define N 10 main() {int i,j,min,tem,a[N]。 /*input data*/ printf(please input ten num:\n)。 for(i=0。iN。i++) { printf(a[%d]=,i)。 scanf(%d,amp。a[i])。} printf(\n)。 for(i=0。iN。i++) printf(%5d,a[i])。 printf(\n)。 /*sort ten num*/ for(i=0。iN1。i++) {min=i。 for(j=i+1。jN。j++) if(a[min]a[j]) min=j。 tem=a[i]。 a[i]=a[min]。 a[min]=tem。 } /*output data*/ printf(After sorted \n)。 for(i=0。iN。i++) printf(%5d,a[i])。 } ============================================================== 【程序 38】 題目:求一個 3*3 矩陣對角線元素之和 :利用雙重 for 循環(huán)控制輸入二維數(shù)組,再將 a[i][i]累加后輸出。 : main() { float a[3][3],sum=0。 int i,j。 printf(please input rectangle element:\n)。 for(i=0。i3。i++) for(j=0。j3。j++) scanf(%f,amp。a[i][j])。 for(i=0。i3。i++) sum=sum+a[i][i]。 printf(duijiaoxian he is %,sum)。 } ============================================================
點擊復制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1