c语言题(编辑修改稿)内容摘要:
) printf(*)。 printf(\n)。 } } ============================================================== 【程序 24】 题目:有一分数序列: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13...求出这个数列的前 20项之和。 :请抓住分子与分母的变化规律。 : 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。 /*这部分是程序的关键,请读者猜猜 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】 题目:利用递归函数调用方式,将所输入的 5个字符,以相反顺序打印出来。 : : include main() { int i=5。 void palin(int n)。 作者: zhlei81 2020122 11:30 回复此发言 6 回复:经典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个人岁数,他说比第 3个人大 2岁。 问第三个人,又说比第 2人大两岁。 问第 2个人,说比第一个人大两岁。 最后 问第一个人,他说是 10岁。 请问第五个人多 大。 :利用递归的方法,递归分为回推和递推两个阶段。 要想知道第五个人岁数,需知道 第四人的岁数,依次类推,推到第一人( 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位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。 1. 程序分析:学会分解出每一位数,如下解释: (这里是一种简单的算法,师专数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位数,判断它是不是回文数。 即 12321是回文数,个位与万位相同,十位与千位相同。 :同 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 回复此发言 7 回复:经典C源程序 100例 程序 31】 题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续 判断第二个字母。 :用情况语句比较好,如果第一个字母一样,则判断用情况语句或 if语句判断第二个字母。 : include void main() { char letter。 printf(please input the first letter of someday\n)。 while ((letter=getch())!=39。 Y39。 )/*当所按字母为 Y时才结束 */ { 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)。 /*设置文本的背景颜色 */ cprintf(This is color %d\r\n, color)。 cprintf(Press any key to continue\r\n)。 getch()。 /*输入字符看不见 */ } } ============================================================== 【程序 33】 题目:学习 gotoxy()与 clrscr()函数 序分析: : include void main(void) { clrscr()。 /*清屏函数 */ textbackground(2)。 gotoxy(1, 5)。 /*定位函数 */ cprintf(Output at row 5 column 1\n)。 textbackground(3)。 gotoxy(20, 10)。 cprintf(Output at row 10 column 20\n)。 } ============================================================== 【程序 34】 题目:练习函数调用 1. 程序分析: : include void hello_world(void) { printf(Hello, world!\n)。 } void three_hellos(void) { int counter。 for (counter = 1。 counter = 3。 counter++) hello_world()。 /*调用此函数 */ } void main(void) { three_hellos()。 /*调用此函数 */ } ============================================================== 【程序 35】 题目:文本颜色设置 : : include void main(void) { int color。 for (color = 1。 color 16。 color++) { textcolor(color)。 /*设置文本颜色 */ cprintf(This is color %d\r\n, color)。 } textcolor(128 + 15)。 cprintf(This is blinking\r\n)。 } ============================================================== 【程序 36】 题目:求 100之内的素数 : : 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+。c语言题(编辑修改稿)
相关推荐
2=led(8i)。 P0=led1|led2。 delay()。 } } while(1)。 } 汇编源代码: ORG 0000H AJMP START ORG 30H S。
会导致曝光过度,所以需要进行减光处理。 减光就是减少闪光的输出强度,你可以在数码相机中进行调节,但这样还是不够的,光线依然很强。 你可以用手遮住闪光灯,注意手指要靠紧,这在一定程度上可 以减少光线强度。 在实际使用中发现,简单的利用餐巾纸这一类柔软的纸张遮挡也能起到很好的效果,让光线变得柔和。 改变闪光的角度 很多人在使用闪光灯进行拍摄时,习惯性地将闪光灯与被摄物体平行,以便让光线变得均匀。
........................................................................ 120 任务 1 编译 RISC_CORE ............................................................................... 121 任务 2 分析报告细节 ........
se 2: printf(“Man\n”)。 } int x = 5。 while ( x 1 ) { printf ( “%d” , x )。 x + + } 计算并输出 s = 1! + 2! + 3! + … +。
567”。 for( i=0,j=strlen(str)1。 ④。 ⑤ ) { ch=str[i]。 ⑥。 str[j]=ch。 } printf(“ %s\n” , str )。 } 用直接选择排序法对数组中的 10 个整数按从小到大排序。 main() { void selectsort(int b[ ],int n)。 int a[ ]={36,12,45,79,34,5,26,51,18
量船底的发射换能器垂直向水下发射一定频率的声波脉冲,以声速 C 在水中传播到水底后产生回波,回波被接收换能器所接收,发射声波与接收回波的时间 t,则换能器表面至水底的距离(水深)为 H=1/2 ct 测深仪在使用前,应进行动态、静态比对试验,有多套测深仪时应进行交叉比对,只有一套仪器时,可以用测深杆进行比对。 回声测深仪的安装,一般安装在测量船的中舷处,因为中舷处在航行中吃水线的变化最小。