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

正文內(nèi)容

c語言題(編輯修改稿)

2025-09-26 10:01 本頁面
 

【文章內(nèi)容簡介】 ) printf(*)。 printf(\n)。 } } ============================================================== 【程序 24】 題目:有一分數(shù)序列: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13...求出這個數(shù)列的前 20項之和。 :請抓住分子與分母的變化規(guī)律。 : main() { int n,t,number=20。 float a=2,b=1,s=0。 for(n=1。n=number。n++) { s=s+a/b。 t=a。a=a+b。b=t。/*這部分是程序的關(guān)鍵,請讀者猜猜 t的作用 */ } printf(sum is %\n,s)。 } ============================================================== 【程序 25】 題目:求 1+2!+3!+...+20!的和 :此程序只是把累加變成了累乘。 : main() { float n,s=0,t=1。 for(n=1。n=20。n++) { t*=n。 s+=t。 } printf(1+2!+3!...+20!=%e\n,s)。 } ============================================================== 【程序 26】 題目:利用遞歸方法求 5!。 :遞歸公式: fn=fn_1*4! : include main() { int i。 int fact()。 for(i=0。i5。i++) printf(\40:%d!=%d\n,i,fact(i))。 } int fact(j) int j。 { int sum。 if(j==0) sum=1。 else sum=j*fact(j1)。 return sum。 } ============================================================== 【程序 27】 題目:利用遞歸函數(shù)調(diào)用方式,將所輸入的 5個字符,以相反順序打印出來。 : : include main() { int i=5。 void palin(int n)。 作者: zhlei81 2020122 11:30 回復(fù)此發(fā)言 6 回復(fù):經(jīng)典C源程序 100例 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。 { int c。 if(n==1) c=10。 else c=age(n1)+2。 return169。 } main() { printf(%d,age(5))。 } ============================================================== 【程序 29】 題目:給一個不多于 5位的正整數(shù),要求:一、求它是幾位數(shù),二、逆序打印出各位數(shù)字。 1. 程序分析:學(xué)會分解出每一位數(shù),如下解釋: (這里是一種簡單的算法,師專數(shù)002班趙鑫提供 ) : 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)。 } 作者: zhlei81 2020122 11:30 回復(fù)此發(fā)言 7 回復(fù):經(jīng)典C源程序 100例 程序 31】 題目:請輸入星期幾的第一個字母來判斷一下是星期幾,如果第一個字母一樣,則繼續(xù) 判斷第二個字母。 :用情況語句比較好,如果第一個字母一樣,則判斷用情況語句或 if語句判斷第二個字母。 : include void main() { char letter。 printf(please input the first letter of someday\n)。 while ((letter=getch())!=39。Y39。)/*當(dāng)所按字母為 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è)置文本的背景顏色 */ cprintf(This is color %d\r\n, color)。 cprintf(Press any key to continue\r\n)。 getch()。/*輸入字符看不見 */ } } ============================================================== 【程序 33】 題目:學(xué)習(xí) 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】 題目:練習(xí)函數(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è)置 : : 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+
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1